Skip to content

A platform for community discussion. Free, open, simple.

PERF: Respect include_thread_original_message option in serializer

Jake Goldsboroughce66d301eda1
diff --git a/plugins/chat/app/serializers/chat/thread_serializer.rb b/plugins/chat/app/serializers/chat/thread_serializer.rb
index b123a08c779..9f5f3e8c1db 100644
--- a/plugins/chat/app/serializers/chat/thread_serializer.rb
+++ b/plugins/chat/app/serializers/chat/thread_serializer.rb
@@ -33,7 +33,7 @@ module Chat
end
def include_original_message?
- @opts[:include_thread_original_message].presence || true
+ @opts[:include_thread_original_message] != false
end
def meta
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/thread-settings-button.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/thread-settings-button.gjs
index 6b34adc1ef5..72b9927f31e 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/thread-settings-button.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/thread-settings-button.gjs
@@ -9,7 +9,7 @@ export default class ChatNavbarThreadSettingsButton extends Component {
@service modal;
get canChangeThreadSettings() {
- if (!this.args.thread) {
+ if (!this.args.thread?.originalMessage) {
return false;
}
diff --git a/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb
index b43a03fc590..53594182659 100644
--- a/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb
@@ -26,6 +26,11 @@ RSpec.describe Chat::Api::ChannelThreadMessagesController do
thread.original_message.id,
message_1.id,
)
+ thread_json =
+ response.parsed_body["messages"].find { |m| m["id"] == thread.original_message.id }[
+ "thread"
+ ]
+ expect(thread_json).not_to have_key("original_message")
end
end