A platform for community discussion. Free, open, simple.
FIX: trashed channel thread view bug (#29192)
David Battersby492cf52bab00
diff --git a/plugins/chat/lib/chat/guardian_extensions.rb b/plugins/chat/lib/chat/guardian_extensions.rbindex 760bb6e9217..57952226b5f 100644--- a/plugins/chat/lib/chat/guardian_extensions.rb+++ b/plugins/chat/lib/chat/guardian_extensions.rb@@ -98,7 +98,7 @@ module Chatenddef can_preview_chat_channel?(chat_channel)- return false unless chat_channel.chatable+ return false if !chat_channel&.chatableif chat_channel.direct_message_channel?chat_channel.chatable.user_can_access?(@user)diff --git a/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rbindex 84c4915bb10..3a0f8a9734d 100644--- a/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rb+++ b/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rb@@ -59,6 +59,15 @@ RSpec.describe Chat::Api::ChannelThreadsController doendend+ context "when channel was deleted" do+ before { thread.channel.trash! }++ it "returns 403" do+ get "/chat/api/channels/#{thread.channel_id}/threads/#{thread.id}"+ expect(response.status).to eq(403)+ end+ end+context "when user cannot access the channel" dobefore dothread.channel.update!(chatable: Fabricate(:private_category, group: Fabricate(:group)))