FIX: stop 'tag_added' rules from firing for normal posts (#165)

This commit is contained in:
Mark VanLandingham 2023-04-21 07:30:03 -05:00 committed by GitHub
parent 9332d77483
commit 9647c7afc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -80,6 +80,8 @@ module DiscourseChatIntegration
# by tag later # by tag later
true true
end end
else
matching_rules = matching_rules.select { |rule| rule.filter != "tag_added" }
end end
# If tagging is enabled, thow away rules that don't apply to this topic # If tagging is enabled, thow away rules that don't apply to this topic

View File

@ -417,6 +417,19 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id) expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
end end
it "doesn't notify when a new regular post is created" do
DiscourseChatIntegration::Rule.create!(
channel: chan1,
filter: "tag_added",
category_id: nil,
tags: [tag.name],
)
post = Fabricate(:post, topic: tagged_topic)
manager.trigger_notifications(post.id)
expect(provider.sent_to_channel_ids).to contain_exactly
end
it "doesn't notify when topic has an unchanged tag present in the rule, even if a new tag is added" do it "doesn't notify when topic has an unchanged tag present in the rule, even if a new tag is added" do
post = set_new_tags_and_return_small_action_post([tag.name, additional_tag.name]) post = set_new_tags_and_return_small_action_post([tag.name, additional_tag.name])