A platform for community discussion. Free, open, simple.
FEATURE: trigger an event when chat channel is trashed (#32844)
Arpit Jalan58d14b075d23
diff --git a/plugins/chat/app/services/chat/trash_channel.rb b/plugins/chat/app/services/chat/trash_channel.rbindex e69d341b81e..ae34390df0e 100644--- a/plugins/chat/app/services/chat/trash_channel.rb+++ b/plugins/chat/app/services/chat/trash_channel.rb@@ -57,6 +57,7 @@ module Chatdef soft_delete_channel(guardian:, channel:)channel.trash!(guardian.user)+ DiscourseEvent.trigger(:chat_channel_trashed, channel, guardian.user)enddef log_channel_deletion(guardian:, channel:)diff --git a/plugins/chat/spec/services/chat/trash_channel_spec.rb b/plugins/chat/spec/services/chat/trash_channel_spec.rbindex 6ab5e3e5b9b..b748f016b39 100644--- a/plugins/chat/spec/services/chat/trash_channel_spec.rb+++ b/plugins/chat/spec/services/chat/trash_channel_spec.rb@@ -54,6 +54,15 @@ RSpec.describe Chat::TrashChannel doexpect(result[:channel].slug).to include("deleted")end+ it "triggers the chat_channel_trashed event" do+ DiscourseEvent.expects(:trigger).with(+ "chat_channel_trashed",+ result[:channel],+ current_user,+ )+ result+ end+it "queues a job to delete channel relations" doexpect { result }.to change(Jobs::Chat::ChannelDelete.jobs, :size).by(1)end