diff --git a/plugins/chat/app/serializers/base_chat_channel_membership_serializer.rb b/plugins/chat/app/serializers/base_chat_channel_membership_serializer.rb new file mode 100644 index 00000000000..90cb7827eed --- /dev/null +++ b/plugins/chat/app/serializers/base_chat_channel_membership_serializer.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class BaseChatChannelMembershipSerializer < ApplicationSerializer + attributes :following, + :muted, + :desktop_notification_level, + :mobile_notification_level, + :chat_channel_id, + :last_read_message_id, + :unread_count, + :unread_mentions +end diff --git a/plugins/chat/app/serializers/chat_channel_serializer.rb b/plugins/chat/app/serializers/chat_channel_serializer.rb index 9193334177d..26f8da8fc04 100644 --- a/plugins/chat/app/serializers/chat_channel_serializer.rb +++ b/plugins/chat/app/serializers/chat_channel_serializer.rb @@ -94,7 +94,8 @@ class ChatChannelSerializer < ApplicationSerializer def current_user_membership @current_user_membership.chat_channel = object - UserChatChannelMembershipSerializer.new( + + BaseChatChannelMembershipSerializer.new( @current_user_membership, scope: scope, root: false, diff --git a/plugins/chat/app/serializers/user_chat_channel_membership_serializer.rb b/plugins/chat/app/serializers/user_chat_channel_membership_serializer.rb index 93e7e5bd85c..18c26222e34 100644 --- a/plugins/chat/app/serializers/user_chat_channel_membership_serializer.rb +++ b/plugins/chat/app/serializers/user_chat_channel_membership_serializer.rb @@ -1,15 +1,6 @@ # frozen_string_literal: true -class UserChatChannelMembershipSerializer < ApplicationSerializer - attributes :following, - :muted, - :desktop_notification_level, - :mobile_notification_level, - :chat_channel_id, - :last_read_message_id, - :unread_count, - :unread_mentions - +class UserChatChannelMembershipSerializer < BaseChatChannelMembershipSerializer has_one :user, serializer: BasicUserSerializer, embed: :objects def user diff --git a/plugins/chat/plugin.rb b/plugins/chat/plugin.rb index 2e9b6b4fa6d..dd379b2152e 100644 --- a/plugins/chat/plugin.rb +++ b/plugins/chat/plugin.rb @@ -145,6 +145,7 @@ after_initialize do load File.expand_path("../app/serializers/structured_channel_serializer.rb", __FILE__) load File.expand_path("../app/serializers/chat_webhook_event_serializer.rb", __FILE__) load File.expand_path("../app/serializers/chat_in_reply_to_serializer.rb", __FILE__) + load File.expand_path("../app/serializers/base_chat_channel_membership_serializer.rb", __FILE__) load File.expand_path("../app/serializers/user_chat_channel_membership_serializer.rb", __FILE__) load File.expand_path("../app/serializers/chat_message_serializer.rb", __FILE__) load File.expand_path("../app/serializers/chat_channel_serializer.rb", __FILE__)