DEV: moves channel-archive-status to channels subscriptions (#19567)

It was quite an oddball because its a global subscription created on each channel. channels manager now allows us to elegantly solve this case.
This commit is contained in:
Joffrey JAFFEUX
2022-12-30 15:30:36 +01:00
committed by GitHub
parent 584a6e3552
commit 908add79de
7 changed files with 63 additions and 45 deletions

View File

@@ -111,7 +111,6 @@ class ChatChannelSerializer < ApplicationSerializer
new_mentions:
@opts[:new_mentions_message_bus_last_id] ||
MessageBus.last_id(ChatPublisher.new_mentions_message_bus_channel(object.id)),
archive_status: MessageBus.last_id("/chat/channel-archive-status"),
},
}
end

View File

@@ -45,6 +45,8 @@ class StructuredChannelSerializer < ApplicationSerializer
channel_edits: chat_message_bus_last_ids[ChatPublisher::CHANNEL_EDITS_MESSAGE_BUS_CHANNEL],
channel_status: chat_message_bus_last_ids[ChatPublisher::CHANNEL_STATUS_MESSAGE_BUS_CHANNEL],
new_channel: chat_message_bus_last_ids[ChatPublisher::NEW_CHANNEL_MESSAGE_BUS_CHANNEL],
archive_status:
chat_message_bus_last_ids[ChatPublisher::CHANNEL_ARCHIVE_STATUS_MESSAGE_BUS_CHANNEL],
}
if id =
@@ -67,6 +69,7 @@ class StructuredChannelSerializer < ApplicationSerializer
ChatPublisher::CHANNEL_EDITS_MESSAGE_BUS_CHANNEL,
ChatPublisher::CHANNEL_STATUS_MESSAGE_BUS_CHANNEL,
ChatPublisher::NEW_CHANNEL_MESSAGE_BUS_CHANNEL,
ChatPublisher::CHANNEL_ARCHIVE_STATUS_MESSAGE_BUS_CHANNEL,
]
if !scope.anonymous?

View File

@@ -230,6 +230,8 @@ module ChatPublisher
)
end
CHANNEL_ARCHIVE_STATUS_MESSAGE_BUS_CHANNEL = "/chat/channel-archive-status"
def self.publish_archive_status(
chat_channel,
archive_status:,
@@ -238,7 +240,7 @@ module ChatPublisher
total_messages:
)
MessageBus.publish(
"/chat/channel-archive-status",
CHANNEL_ARCHIVE_STATUS_MESSAGE_BUS_CHANNEL,
{
chat_channel_id: chat_channel.id,
archive_failed: archive_status == :failed,