DEV: Better error message when user is not allowed to user tags (#26380)

When a topic fails to be created due to the user not having permission to add tags to the topic, the error message that you get is `There was an error tagging the topic` which is very generic and doesn't explain where/what the problem is. This commit adds a clearer error message for this scenario.
This commit is contained in:
Osama Sayegh 2024-03-27 12:57:10 +03:00 committed by GitHub
parent 72c4709a5a
commit 0b34b4cbe9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -5160,6 +5160,7 @@ en:
limited_to_one_tag_from_group: "The tags %{tags} cannot be used simultaneously. Please include only one of them." limited_to_one_tag_from_group: "The tags %{tags} cannot be used simultaneously. Please include only one of them."
invalid_target_tag: "cannot be a synonym of a synonym" invalid_target_tag: "cannot be a synonym of a synonym"
synonyms_exist: "is not allowed while synonyms exist" synonyms_exist: "is not allowed while synonyms exist"
user_not_permitted: "You're not allowed to tag topics"
rss_by_tag: "Topics tagged %{tag}" rss_by_tag: "Topics tagged %{tag}"
finish_installation: finish_installation:

View File

@ -214,9 +214,11 @@ module DiscourseTagging
new_tag_names: topic.tags.map(&:name), new_tag_names: topic.tags.map(&:name),
) )
return true true
else
topic.errors.add(:base, I18n.t("tags.user_not_permitted"))
false
end end
false
end end
def self.validate_category_tags(guardian, model, category, tags = []) def self.validate_category_tags(guardian, model, category, tags = [])