Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate featured tags #19403

Merged
merged 3 commits into from
Oct 22, 2022
Merged

Conversation

noellabo
Copy link
Contributor

There was a bug that allowed featured tags with the same tag to be created because the unique constraint was not set. Fix this.

@trwnh
Copy link
Member

trwnh commented Oct 21, 2022

Fix #19220 ?

@noellabo noellabo marked this pull request as draft October 21, 2022 09:32
@noellabo
Copy link
Contributor Author

Oh, that's exactly what I'm talking about.

Error handling on the setting page was missing. Please wait a moment.

@noellabo noellabo marked this pull request as ready for review October 21, 2022 10:52
@@ -58,5 +60,6 @@ def validate_featured_tags_limit
def validate_tag_name
errors.add(:name, :blank) if @name.blank?
errors.add(:name, :invalid) unless @name.match?(/\A(#{Tag::HASHTAG_NAME_RE})\z/i)
errors.add(:name, I18n.t('featured_tags.errors.duplicate_hashtag')) if FeaturedTag.by_name(@name).where(account_id: account_id).exists?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should trigger the normal :taken error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it.

@Gargron Gargron merged commit 53e8674 into mastodon:main Oct 22, 2022
@noellabo noellabo deleted the fix-duplicate-featured-tags branch October 23, 2022 06:29
kadoshita pushed a commit to kadoshita/mastodon that referenced this pull request Nov 19, 2022
* Fix duplicate featured tags

* Add unique tag name validator

* Fix error message
nametoolong pushed a commit to nametoolong/nuage that referenced this pull request Nov 20, 2022
* Fix duplicate featured tags

* Add unique tag name validator

* Fix error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants