mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-03-06 09:49:28 +00:00
FIX: Topic changing category was not triggering notifications (#244)
We moved `category_changed` notification to be a `whisper` but we forgot to update the check in `manager.rb` to verify not for a `small_post` but for a whisper. Added a test to cover this case.
This commit is contained in:
parent
f0cac677c2
commit
8498d88ccb
@ -15,10 +15,10 @@ module DiscourseChatIntegration
|
|||||||
# Abort if the post is blank
|
# Abort if the post is blank
|
||||||
return if post.blank?
|
return if post.blank?
|
||||||
|
|
||||||
# Abort if post is not either regular or a 'category_changed' small action
|
# Abort if post is not either regular or a 'category_changed' whisper
|
||||||
if (post.post_type != Post.types[:regular]) &&
|
if (post.post_type != Post.types[:regular]) &&
|
||||||
!(
|
!(
|
||||||
post.post_type == Post.types[:small_action] &&
|
post.post_type == Post.types[:whisper] &&
|
||||||
%w[category_changed].include?(post.action_code)
|
%w[category_changed].include?(post.action_code)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
@ -346,5 +346,41 @@ 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "with whispers and actions enabled" do
|
||||||
|
before do
|
||||||
|
SiteSetting.create_post_for_category_and_tag_changes = true
|
||||||
|
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should notify about category changes" do
|
||||||
|
DiscourseChatIntegration::Rule.create!(
|
||||||
|
channel: chan1,
|
||||||
|
filter: "watch",
|
||||||
|
category_id: category.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
new_category = Fabricate(:category)
|
||||||
|
DiscourseChatIntegration::Rule.create!(
|
||||||
|
channel: chan1,
|
||||||
|
filter: "watch",
|
||||||
|
category_id: new_category.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
manager.trigger_notifications(first_post.id)
|
||||||
|
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
|
||||||
|
|
||||||
|
# Change category
|
||||||
|
PostRevisor.new(first_post, topic).revise!(
|
||||||
|
Discourse.system_user,
|
||||||
|
category_id: new_category.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
last_topic_post = topic.posts.last
|
||||||
|
manager.trigger_notifications(last_topic_post.id)
|
||||||
|
expect(provider.sent_messages.count).to eq(2)
|
||||||
|
expect(provider.sent_messages.last).to eq(post: last_topic_post.id, channel: chan1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user