FIX: Hashtag error in PrettyText when processing email (#22680)

Followup to b583872eed
and 54001060ea

Another place where we need to filter hashtag types to
only enabled ones is PrettyText, though the latter PR
above should also already make it so the correct priority
types are passed.

This is causing errors in the email processing workflow
for some customers (presumably ones with tagging disabled).
This commit is contained in:
Martin Brennan 2023-07-19 10:52:18 +10:00 committed by GitHub
parent 7cee80d699
commit 3be9e6c97e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -125,6 +125,11 @@ module PrettyText
cooking_user = User.find(cooking_user_id)
end
types_in_priority_order =
types_in_priority_order.select do |type|
HashtagAutocompleteService.data_source_types.include?(type)
end
result =
HashtagAutocompleteService.new(Guardian.new(cooking_user)).lookup(
[slug],

View File

@ -163,6 +163,13 @@ RSpec.describe PrettyText::Helpers do
)
end
it "does not return any results for disabled types" do
SiteSetting.tagging_enabled = false
expect(
PrettyText::Helpers.hashtag_lookup("somecooltag::tag", user.id, %w[category tag]),
).to eq(nil)
end
it "returns nil when no tag or category that matches exists" do
expect(PrettyText::Helpers.hashtag_lookup("blah", user.id, %w[category tag])).to eq(nil)
end