FIX: Automation should not fire on PMS
automation on topic tags should not fire on PMS
This commit is contained in:
parent
c72c01e955
commit
e906290311
|
@ -103,6 +103,8 @@ after_initialize do
|
||||||
triggerables %i[topic_tags_changed]
|
triggerables %i[topic_tags_changed]
|
||||||
|
|
||||||
script do |context, fields, automation|
|
script do |context, fields, automation|
|
||||||
|
next if context["topic"].private_message?
|
||||||
|
|
||||||
# DiscourseTagging.tag_topic_by_names runs on topic creation and on tags change
|
# DiscourseTagging.tag_topic_by_names runs on topic creation and on tags change
|
||||||
# we only want to send a message when tags change
|
# we only want to send a message when tags change
|
||||||
next if context["topic"].new_record?
|
next if context["topic"].new_record?
|
||||||
|
|
|
@ -29,6 +29,8 @@ RSpec.describe "Triggering notifications" do
|
||||||
SiteSetting.create_tag_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
SiteSetting.create_tag_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||||
SiteSetting.tag_topic_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
SiteSetting.tag_topic_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||||
|
|
||||||
|
SiteSetting.pm_tags_allowed_for_groups = Group::AUTO_GROUPS[:everyone]
|
||||||
|
|
||||||
automation.upsert_field!(
|
automation.upsert_field!(
|
||||||
"watching_categories",
|
"watching_categories",
|
||||||
"categories",
|
"categories",
|
||||||
|
@ -84,5 +86,24 @@ RSpec.describe "Triggering notifications" do
|
||||||
)
|
)
|
||||||
expect(validated_provider.sent_messages.length).to eq(0)
|
expect(validated_provider.sent_messages.length).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not trigger notifications for PMs" do
|
||||||
|
automation.upsert_field!(
|
||||||
|
"watching_categories",
|
||||||
|
"categories",
|
||||||
|
{ "value" => [nil] },
|
||||||
|
target: "trigger",
|
||||||
|
)
|
||||||
|
|
||||||
|
topic =
|
||||||
|
TopicCreator.create(
|
||||||
|
admin,
|
||||||
|
Guardian.new(admin),
|
||||||
|
valid_attrs.merge(archetype: Archetype.private_message, target_usernames: admin.username),
|
||||||
|
)
|
||||||
|
|
||||||
|
DiscourseTagging.tag_topic_by_names(topic, Guardian.new(admin), [tag.name])
|
||||||
|
expect(validated_provider.sent_messages.length).to eq(0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue