FIX: Add MessageBust.last_id to chat channel subscriptions (#19255)
This commit adds variousMessageBus.last_ids to serializer payloads for chat channels and the chat view (for chat live pane) so we can use those IDs when subscribing to MessageBus channels from chat. This allows us to ensure that any messages created between the server being hit and the UI loaded and subscribing end up being delivered to the client, rather than just silently dropped. This commit also fixes an issue where we were subscribing to the new-messages and new-mentions MessageBus channels multiple times when following/unfollowing a channel multiple times.
This commit is contained in:
parent
a2cec6366f
commit
8437081d94
|
@ -18,7 +18,8 @@ class ChatChannelSerializer < ApplicationSerializer
|
|||
:total_messages,
|
||||
:archive_topic_id,
|
||||
:memberships_count,
|
||||
:current_user_membership
|
||||
:current_user_membership,
|
||||
:message_bus_last_ids
|
||||
|
||||
def initialize(object, opts)
|
||||
super(object, opts)
|
||||
|
@ -94,6 +95,13 @@ class ChatChannelSerializer < ApplicationSerializer
|
|||
).as_json
|
||||
end
|
||||
|
||||
def message_bus_last_ids
|
||||
{
|
||||
new_messages: MessageBus.last_id("/chat/#{object.id}/new-messages"),
|
||||
new_mentions: MessageBus.last_id("/chat/#{object.id}/new-mentions"),
|
||||
}
|
||||
end
|
||||
|
||||
alias_method :include_archive_topic_id?, :include_archive_status?
|
||||
alias_method :include_total_messages?, :include_archive_status?
|
||||
alias_method :include_archived_messages?, :include_archive_status?
|
||||
|
|
|
@ -22,6 +22,7 @@ class ChatViewSerializer < ApplicationSerializer
|
|||
can_moderate: scope.can_moderate_chat?(object.chat_channel.chatable),
|
||||
can_delete_self: scope.can_delete_own_chats?(object.chat_channel.chatable),
|
||||
can_delete_others: scope.can_delete_other_chats?(object.chat_channel.chatable),
|
||||
channel_message_bus_last_id: MessageBus.last_id("/chat/#{object.chat_channel.id}"),
|
||||
}
|
||||
meta_hash[:can_load_more_past] = object.can_load_more_past unless object.can_load_more_past.nil?
|
||||
meta_hash[
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class StructuredChannelSerializer < ApplicationSerializer
|
||||
attributes :public_channels, :direct_message_channels
|
||||
attributes :public_channels, :direct_message_channels, :message_bus_last_ids
|
||||
|
||||
def public_channels
|
||||
object[:public_channels].map do |channel|
|
||||
|
@ -29,4 +29,19 @@ class StructuredChannelSerializer < ApplicationSerializer
|
|||
return if scope.anonymous?
|
||||
object[:memberships].find { |membership| membership.chat_channel_id == channel_id }
|
||||
end
|
||||
|
||||
def message_bus_last_ids
|
||||
last_ids = {
|
||||
channel_metadata: MessageBus.last_id("/chat/channel-metadata"),
|
||||
channel_edits: MessageBus.last_id("/chat/channel-edits"),
|
||||
channel_status: MessageBus.last_id("/chat/channel-status"),
|
||||
new_channel: MessageBus.last_id("/chat/new-channel"),
|
||||
}
|
||||
if !scope.anonymous?
|
||||
last_ids[:user_tracking_state] = MessageBus.last_id(
|
||||
"/chat/user-tracking-state/#{scope.user.id}",
|
||||
)
|
||||
end
|
||||
last_ids
|
||||
end
|
||||
end
|
||||
|
|
|
@ -403,6 +403,8 @@ export default Component.extend({
|
|||
can_flag: messages.resultSetMeta.can_flag,
|
||||
user_silenced: messages.resultSetMeta.user_silenced,
|
||||
can_moderate: messages.resultSetMeta.can_moderate,
|
||||
channel_message_bus_last_id:
|
||||
messages.resultSetMeta.channel_message_bus_last_id,
|
||||
},
|
||||
registeredChatChannelId: this.chatChannel.id,
|
||||
});
|
||||
|
@ -1407,13 +1409,17 @@ export default Component.extend({
|
|||
|
||||
_subscribeToUpdates(channelId) {
|
||||
this._unsubscribeToUpdates(channelId);
|
||||
this.messageBus.subscribe(`/chat/${channelId}`, (busData) => {
|
||||
if (!this.details.can_load_more_future || busData.type !== "sent") {
|
||||
this.handleMessage(busData);
|
||||
} else {
|
||||
this.set("hasNewMessages", true);
|
||||
}
|
||||
});
|
||||
this.messageBus.subscribe(
|
||||
`/chat/${channelId}`,
|
||||
(busData) => {
|
||||
if (!this.details.can_load_more_future || busData.type !== "sent") {
|
||||
this.handleMessage(busData);
|
||||
} else {
|
||||
this.set("hasNewMessages", true);
|
||||
}
|
||||
},
|
||||
this.details.channel_message_bus_last_id
|
||||
);
|
||||
},
|
||||
|
||||
@bind
|
||||
|
|
|
@ -101,7 +101,7 @@ export default {
|
|||
if (currentUser?.chat_channels) {
|
||||
this.chatService.setupWithPreloadedChannels(currentUser.chat_channels);
|
||||
} else {
|
||||
this.chatService.getChannels();
|
||||
this.chatService.setupWithoutPreloadedChannels();
|
||||
}
|
||||
|
||||
const chatNotificationManager = container.lookup(
|
||||
|
|
|
@ -79,11 +79,6 @@ export default class Chat extends Service {
|
|||
|
||||
if (this.userCanChat) {
|
||||
this.set("allChannels", []);
|
||||
this._subscribeToNewChannelUpdates();
|
||||
this._subscribeToUserTrackingChannel();
|
||||
this._subscribeToChannelEdits();
|
||||
this._subscribeToChannelMetadata();
|
||||
this._subscribeToChannelStatusChange();
|
||||
this.presenceChannel = this.presence.getChannel("/chat/online");
|
||||
this.draftStore = {};
|
||||
|
||||
|
@ -118,10 +113,25 @@ export default class Chat extends Service {
|
|||
setupWithPreloadedChannels(channels) {
|
||||
this.currentUser.set("chat_channel_tracking_state", {});
|
||||
this._processChannels(channels || {});
|
||||
this.subscribeToChannelMessageBus();
|
||||
this.userChatChannelTrackingStateChanged();
|
||||
this.appEvents.trigger("chat:refresh-channels");
|
||||
}
|
||||
|
||||
setupWithoutPreloadedChannels() {
|
||||
this.getChannels().then(() => {
|
||||
this.subscribeToChannelMessageBus();
|
||||
});
|
||||
}
|
||||
|
||||
subscribeToChannelMessageBus() {
|
||||
this._subscribeToNewChannelUpdates();
|
||||
this._subscribeToUserTrackingChannel();
|
||||
this._subscribeToChannelEdits();
|
||||
this._subscribeToChannelMetadata();
|
||||
this._subscribeToChannelStatusChange();
|
||||
}
|
||||
|
||||
willDestroy() {
|
||||
super.willDestroy(...arguments);
|
||||
|
||||
|
@ -342,6 +352,8 @@ export default class Chat extends Service {
|
|||
}
|
||||
|
||||
_processChannels(channels) {
|
||||
// Must be set first because `processChannels` relies on this data.
|
||||
this.set("messageBusLastIds", channels.message_bus_last_ids);
|
||||
this.setProperties({
|
||||
publicChannels: A(
|
||||
this.sortPublicChannels(
|
||||
|
@ -593,29 +605,37 @@ export default class Chat extends Service {
|
|||
}
|
||||
|
||||
_subscribeToChannelMetadata() {
|
||||
this.messageBus.subscribe("/chat/channel-metadata", (busData) => {
|
||||
this.getChannelBy("id", busData.chat_channel_id).then((channel) => {
|
||||
if (channel) {
|
||||
channel.setProperties({
|
||||
memberships_count: busData.memberships_count,
|
||||
});
|
||||
this.appEvents.trigger("chat:refresh-channel-members");
|
||||
}
|
||||
});
|
||||
});
|
||||
this.messageBus.subscribe(
|
||||
"/chat/channel-metadata",
|
||||
(busData) => {
|
||||
this.getChannelBy("id", busData.chat_channel_id).then((channel) => {
|
||||
if (channel) {
|
||||
channel.setProperties({
|
||||
memberships_count: busData.memberships_count,
|
||||
});
|
||||
this.appEvents.trigger("chat:refresh-channel-members");
|
||||
}
|
||||
});
|
||||
},
|
||||
this.messageBusLastIds.channel_metadata
|
||||
);
|
||||
}
|
||||
|
||||
_subscribeToChannelEdits() {
|
||||
this.messageBus.subscribe("/chat/channel-edits", (busData) => {
|
||||
this.getChannelBy("id", busData.chat_channel_id).then((channel) => {
|
||||
if (channel) {
|
||||
channel.setProperties({
|
||||
title: busData.name,
|
||||
description: busData.description,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
this.messageBus.subscribe(
|
||||
"/chat/channel-edits",
|
||||
(busData) => {
|
||||
this.getChannelBy("id", busData.chat_channel_id).then((channel) => {
|
||||
if (channel) {
|
||||
channel.setProperties({
|
||||
title: busData.name,
|
||||
description: busData.description,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
this.messageBusLastIds.channel_edits
|
||||
);
|
||||
}
|
||||
|
||||
_subscribeToChannelStatusChange() {
|
||||
|
@ -641,7 +661,7 @@ export default class Chat extends Service {
|
|||
}
|
||||
|
||||
this.appEvents.trigger("chat:refresh-channel", channel.id);
|
||||
});
|
||||
}, this.messageBusLastIds.channel_status);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -658,9 +678,13 @@ export default class Chat extends Service {
|
|||
}
|
||||
|
||||
_subscribeToNewChannelUpdates() {
|
||||
this.messageBus.subscribe("/chat/new-channel", (busData) => {
|
||||
this.startTrackingChannel(ChatChannel.create(busData.chat_channel));
|
||||
});
|
||||
this.messageBus.subscribe(
|
||||
"/chat/new-channel",
|
||||
(busData) => {
|
||||
this.startTrackingChannel(ChatChannel.create(busData.chat_channel));
|
||||
},
|
||||
this.messageBusLastIds.new_channel
|
||||
);
|
||||
}
|
||||
|
||||
_unsubscribeFromNewDmChannelUpdates() {
|
||||
|
@ -672,54 +696,71 @@ export default class Chat extends Service {
|
|||
return;
|
||||
}
|
||||
|
||||
// We do this first so we don't multi-subscribe to mention + messages
|
||||
// messageBus channels for this chat channel, since _subscribeToSingleUpdateChannel
|
||||
// is called from multiple places.
|
||||
this._unsubscribeFromChatChannel(channel);
|
||||
|
||||
if (!channel.isDirectMessageChannel) {
|
||||
this._subscribeToMentionChannel(channel);
|
||||
}
|
||||
|
||||
this.messageBus.subscribe(`/chat/${channel.id}/new-messages`, (busData) => {
|
||||
const trackingState =
|
||||
this.currentUser.chat_channel_tracking_state[channel.id];
|
||||
|
||||
if (busData.user_id === this.currentUser.id) {
|
||||
// User sent message, update tracking state to no unread
|
||||
trackingState.set("chat_message_id", busData.message_id);
|
||||
} else {
|
||||
// Ignored user sent message, update tracking state to no unread
|
||||
if (this.currentUser.ignored_users.includes(busData.username)) {
|
||||
trackingState.set("chat_message_id", busData.message_id);
|
||||
} else {
|
||||
// Message from other user. Increment trackings state
|
||||
if (busData.message_id > (trackingState.chat_message_id || 0)) {
|
||||
trackingState.set("unread_count", trackingState.unread_count + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.userChatChannelTrackingStateChanged();
|
||||
|
||||
// Update last_message_sent_at timestamp for channel if direct message
|
||||
const dmChatChannel = (this.directMessageChannels || []).findBy(
|
||||
"id",
|
||||
parseInt(channel.id, 10)
|
||||
);
|
||||
if (dmChatChannel) {
|
||||
dmChatChannel.set("last_message_sent_at", new Date());
|
||||
this.reSortDirectMessageChannels();
|
||||
}
|
||||
});
|
||||
this._subscribeToNewMessagesChannel(channel);
|
||||
}
|
||||
|
||||
_subscribeToMentionChannel(channel) {
|
||||
this.messageBus.subscribe(`/chat/${channel.id}/new-mentions`, () => {
|
||||
const trackingState =
|
||||
this.currentUser.chat_channel_tracking_state[channel.id];
|
||||
if (trackingState) {
|
||||
trackingState.set(
|
||||
"unread_mentions",
|
||||
(trackingState.unread_mentions || 0) + 1
|
||||
);
|
||||
this.messageBus.subscribe(
|
||||
`/chat/${channel.id}/new-mentions`,
|
||||
() => {
|
||||
const trackingState =
|
||||
this.currentUser.chat_channel_tracking_state[channel.id];
|
||||
if (trackingState) {
|
||||
trackingState.set(
|
||||
"unread_mentions",
|
||||
(trackingState.unread_mentions || 0) + 1
|
||||
);
|
||||
this.userChatChannelTrackingStateChanged();
|
||||
}
|
||||
},
|
||||
channel.message_bus_last_ids.new_mentions
|
||||
);
|
||||
}
|
||||
|
||||
_subscribeToNewMessagesChannel(channel) {
|
||||
this.messageBus.subscribe(
|
||||
`/chat/${channel.id}/new-messages`,
|
||||
(busData) => {
|
||||
const trackingState =
|
||||
this.currentUser.chat_channel_tracking_state[channel.id];
|
||||
|
||||
if (busData.user_id === this.currentUser.id) {
|
||||
// User sent message, update tracking state to no unread
|
||||
trackingState.set("chat_message_id", busData.message_id);
|
||||
} else {
|
||||
// Ignored user sent message, update tracking state to no unread
|
||||
if (this.currentUser.ignored_users.includes(busData.username)) {
|
||||
trackingState.set("chat_message_id", busData.message_id);
|
||||
} else {
|
||||
// Message from other user. Increment trackings state
|
||||
if (busData.message_id > (trackingState.chat_message_id || 0)) {
|
||||
trackingState.set("unread_count", trackingState.unread_count + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.userChatChannelTrackingStateChanged();
|
||||
}
|
||||
});
|
||||
|
||||
// Update last_message_sent_at timestamp for channel if direct message
|
||||
const dmChatChannel = (this.directMessageChannels || []).findBy(
|
||||
"id",
|
||||
parseInt(channel.id, 10)
|
||||
);
|
||||
if (dmChatChannel) {
|
||||
dmChatChannel.set("last_message_sent_at", new Date());
|
||||
this.reSortDirectMessageChannels();
|
||||
}
|
||||
},
|
||||
channel.message_bus_last_ids.new_messages
|
||||
);
|
||||
}
|
||||
|
||||
async followChannel(channel) {
|
||||
|
@ -779,7 +820,8 @@ export default class Chat extends Service {
|
|||
trackingState.set("unread_mentions", 0);
|
||||
this.userChatChannelTrackingStateChanged();
|
||||
}
|
||||
}
|
||||
},
|
||||
this.messageBusLastIds.user_tracking_state
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,21 @@ RSpec.describe Chat::ChatChannelsController do
|
|||
expect(cc["current_user_membership"]["unread_mentions"]).to eq(1)
|
||||
end
|
||||
|
||||
it "returns the last message bus ids for various message bus channels scoped to this channel id" do
|
||||
sign_in(admin)
|
||||
get "/chat/chat_channels.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(response.parsed_body["message_bus_last_ids"]["channel_metadata"]).not_to eq(nil)
|
||||
expect(response.parsed_body["message_bus_last_ids"]["channel_edits"]).not_to eq(nil)
|
||||
expect(response.parsed_body["message_bus_last_ids"]["channel_status"]).not_to eq(nil)
|
||||
expect(response.parsed_body["message_bus_last_ids"]["new_channel"]).not_to eq(nil)
|
||||
|
||||
first_channel = response.parsed_body["public_channels"][0]
|
||||
expect(first_channel["message_bus_last_ids"]["new_messages"]).not_to eq(nil)
|
||||
expect(first_channel["message_bus_last_ids"]["new_mentions"]).not_to eq(nil)
|
||||
end
|
||||
|
||||
describe "direct messages" do
|
||||
fab!(:user1) { Fabricate(:user) }
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
|
|
|
@ -137,6 +137,11 @@ RSpec.describe Chat::ChatController do
|
|||
expect(reactions[smile_emoji]["reacted"]).to be false
|
||||
end
|
||||
|
||||
it "sends the last message bus id for the channel" do
|
||||
get "/chat/#{chat_channel.id}/messages.json", params: { page_size: page_size }
|
||||
expect(response.parsed_body["meta"]["channel_message_bus_last_id"]).not_to eq(nil)
|
||||
end
|
||||
|
||||
describe "scrolling to the past" do
|
||||
it "returns the correct messages in created_at, id order" do
|
||||
get "/chat/#{chat_channel.id}/messages.json",
|
||||
|
@ -1030,7 +1035,8 @@ RSpec.describe Chat::ChatController do
|
|||
}.to change {
|
||||
user.notifications.where(notification_type: Notification.types[:chat_invitation]).count
|
||||
}.by(1)
|
||||
notification = user.notifications.where(notification_type: Notification.types[:chat_invitation]).last
|
||||
notification =
|
||||
user.notifications.where(notification_type: Notification.types[:chat_invitation]).last
|
||||
parsed_data = JSON.parse(notification[:data])
|
||||
expect(parsed_data["chat_channel_title"]).to eq(chat_channel.title(user))
|
||||
expect(parsed_data["chat_channel_slug"]).to eq(chat_channel.slug)
|
||||
|
|
|
@ -56,33 +56,30 @@ describe "Using #hashtag autocompletion to search for and lookup channels",
|
|||
expect(hashtag_results.map(&:text)).to eq(["Raspberry", "razed x 0", "Random"])
|
||||
end
|
||||
|
||||
# TODO (martin) Commenting this out for now, we need to add the MessageBus
|
||||
# last_message_id to our chat subscriptions in JS for this to work, since it
|
||||
# relies on a MessageBus "sent" event to be published to substitute the
|
||||
# staged message ID for the real one.
|
||||
xit "cooks the hashtags for channels, categories, and tags serverside when the chat message is saved to the database" do
|
||||
it "cooks the hashtags for channels, categories, and tags serverside when the chat message is saved to the database" do
|
||||
chat_page.visit_channel(channel1)
|
||||
expect(chat_channel_page).to have_no_loading_skeleton
|
||||
chat_channel_page.type_in_composer("this is #random and this is #raspberry and this is #razed which is cool")
|
||||
chat_channel_page.type_in_composer("this is #random and this is #raspberry-beret and this is #razed which is cool")
|
||||
chat_channel_page.click_send_message
|
||||
|
||||
message = nil
|
||||
try_until_success do
|
||||
expect(ChatMessage.exists?(user: user, message: "this is #random and this is #raspberry and this is #razed which is cool")).to eq(true)
|
||||
message = ChatMessage.find_by(user: user, message: "this is #random and this is #raspberry-beret and this is #razed which is cool")
|
||||
expect(message).not_to eq(nil)
|
||||
end
|
||||
message = ChatMessage.where(user: user).last
|
||||
expect(chat_channel_page).to have_message(id: message.id)
|
||||
|
||||
within chat_channel_page.message_by_id(message.id) do
|
||||
cooked_hashtags = page.all(".hashtag-cooked", count: 3)
|
||||
|
||||
expect(cooked_hashtags[0]["outerHTML"]).to eq(<<~HTML.chomp)
|
||||
<a class=\"hashtag-cooked\" href=\"#{channel1.relative_url}\" data-type=\"channel\" data-slug=\"random\"><span><svg class=\"fa d-icon d-icon-comment svg-icon svg-node\"><use href=\"#comment\"></use></svg>Random</span></a>
|
||||
<a class=\"hashtag-cooked\" href=\"#{channel2.relative_url}\" data-type=\"channel\" data-slug=\"random\"><svg class=\"fa d-icon d-icon-comment svg-icon svg-node\"><use href=\"#comment\"></use></svg><span>Random</span></a>
|
||||
HTML
|
||||
expect(cooked_hashtags[1]["outerHTML"]).to eq(<<~HTML.chomp)
|
||||
<a class=\"hashtag-cooked\" href=\"#{category.url}\" data-type=\"category\" data-slug=\"raspberry\"><span><svg class=\"fa d-icon d-icon-folder svg-icon svg-node\"><use href=\"#folder\"></use></svg>raspberry</span></a>
|
||||
<a class=\"hashtag-cooked\" href=\"#{category.url}\" data-type=\"category\" data-slug=\"raspberry-beret\"><svg class=\"fa d-icon d-icon-folder svg-icon svg-node\"><use href=\"#folder\"></use></svg><span>Raspberry</span></a>
|
||||
HTML
|
||||
expect(cooked_hashtags[2]["outerHTML"]).to eq(<<~HTML.chomp)
|
||||
<a class=\"hashtag-cooked\" href=\"#{tag.url}\" data-type=\"tag\" data-slug=\"razed\"><span><svg class=\"fa d-icon d-icon-tag svg-icon svg-node\"><use href=\"#tag\"></use></svg>razed</span></a>
|
||||
<a class=\"hashtag-cooked\" href=\"#{tag.url}\" data-type=\"tag\" data-slug=\"razed\"><svg class=\"fa d-icon d-icon-tag svg-icon svg-node\"><use href=\"#tag\"></use></svg><span>razed</span></a>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,13 @@ acceptance("Discourse Chat - browse channels", function (needs) {
|
|||
return helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -14,8 +14,15 @@ acceptance("Discourse Chat - chat channel info", function (needs) {
|
|||
const channel = fabricators.chatChannel();
|
||||
server.get("/chat/chat_channels.json", () => {
|
||||
return helper.response({
|
||||
publicMessageChannels: [channel],
|
||||
directMessageChannels: [],
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
server.get("/chat/chat_channels/:id.json", () => {
|
||||
|
|
|
@ -26,6 +26,13 @@ acceptance(
|
|||
direct_message_channels: cloneJSON(directMessageChannels).mapBy(
|
||||
"chat_channel"
|
||||
),
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -79,6 +79,13 @@ acceptance("Discourse Chat - Chat live pane collapse", function (needs) {
|
|||
helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -59,6 +59,13 @@ acceptance("Discourse Chat - Chat live pane mobile", function (needs) {
|
|||
helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -57,9 +57,20 @@ acceptance("Discourse Chat - Chat live pane", function (needs) {
|
|||
id: 1,
|
||||
title: "something",
|
||||
current_user_membership: { following: true },
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -85,9 +85,20 @@ acceptance(
|
|||
id: 1,
|
||||
title: "something",
|
||||
current_user_membership: { following: true },
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -198,9 +209,17 @@ acceptance(
|
|||
id: 1,
|
||||
title: "something",
|
||||
current_user_membership: { following: true },
|
||||
message_bus_last_ids: { new_mentions: 0, new_messages: 0 },
|
||||
},
|
||||
],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -246,6 +265,13 @@ acceptance(
|
|||
helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -292,6 +318,13 @@ acceptance(
|
|||
helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ acceptance("Discourse Chat | User Preferences", function (needs) {
|
|||
needs.settings({ chat_enabled: true });
|
||||
needs.pretender(preferencesPretender);
|
||||
|
||||
test("when user has not chat sound set", async function (assert) {
|
||||
test("when user has no chat sound set", async function (assert) {
|
||||
const sounds = Object.keys(CHAT_SOUNDS);
|
||||
await visit("/u/eviltrout/preferences/chat");
|
||||
const dropdown = selectKit("#user_chat_sounds");
|
||||
|
|
|
@ -34,12 +34,23 @@ acceptance("Discourse Chat - Sidebar - User Status", function (needs) {
|
|||
},
|
||||
chatable_type: "DirectMessage",
|
||||
title: "@user1",
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
};
|
||||
|
||||
server.get("/chat/chat_channels.json", () => {
|
||||
return helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [directMessageChannel],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -474,6 +474,13 @@ acceptance(
|
|||
helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -525,6 +532,13 @@ acceptance(
|
|||
helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ acceptance("Discourse Chat - Core Sidebar", function (needs) {
|
|||
muted: true,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
});
|
||||
directChannels.push({
|
||||
chatable: {
|
||||
|
@ -82,6 +86,10 @@ acceptance("Discourse Chat - Core Sidebar", function (needs) {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
});
|
||||
|
||||
server.get("/chat/chat_channels.json", () => {
|
||||
|
@ -97,6 +105,10 @@ acceptance("Discourse Chat - Core Sidebar", function (needs) {
|
|||
unread_count: 0,
|
||||
unread_mentions: 0,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
|
@ -108,6 +120,10 @@ acceptance("Discourse Chat - Core Sidebar", function (needs) {
|
|||
unread_count: 1,
|
||||
unread_mentions: 0,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
|
@ -121,6 +137,10 @@ acceptance("Discourse Chat - Core Sidebar", function (needs) {
|
|||
unread_count: 1,
|
||||
unread_mentions: 1,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
|
@ -132,15 +152,30 @@ acceptance("Discourse Chat - Core Sidebar", function (needs) {
|
|||
unread_count: 1,
|
||||
unread_mentions: 1,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
direct_message_channels: directChannels,
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
server.get("/chat/1/messages.json", () =>
|
||||
helper.response({
|
||||
meta: { can_chat: true, user_silenced: false },
|
||||
meta: {
|
||||
can_chat: true,
|
||||
user_silenced: false,
|
||||
channel_message_bus_last_id: 0,
|
||||
},
|
||||
chat_messages: [],
|
||||
})
|
||||
);
|
||||
|
@ -510,6 +545,10 @@ acceptance("Discourse Chat - Plugin Sidebar", function (needs) {
|
|||
unread_count: 1,
|
||||
unread_mentions: 1,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
|
@ -521,6 +560,10 @@ acceptance("Discourse Chat - Plugin Sidebar", function (needs) {
|
|||
unread_count: 1,
|
||||
unread_mentions: 1,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
|
@ -532,9 +575,20 @@ acceptance("Discourse Chat - Plugin Sidebar", function (needs) {
|
|||
unread_count: 1,
|
||||
unread_mentions: 1,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -568,6 +622,13 @@ acceptance(
|
|||
return helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -604,6 +665,13 @@ acceptance(
|
|||
return helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -640,6 +708,13 @@ acceptance(
|
|||
return helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -679,6 +754,13 @@ acceptance(
|
|||
return helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: directChannels,
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -55,6 +55,13 @@ acceptance("Discourse Chat - Create channel modal", function (needs) {
|
|||
helper.response({
|
||||
public_channels: [],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -13,6 +13,13 @@ acceptance("Discourse Chat - delete chat channel modal", function (needs) {
|
|||
return helper.response({
|
||||
public_channels: [fabricators.chatChannel({ id: 2 })],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -32,6 +32,10 @@ export const directMessageChannels = [
|
|||
following: true,
|
||||
},
|
||||
last_message_sent_at: "2021-07-20T08:14:16.950Z",
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -63,6 +67,10 @@ export const directMessageChannels = [
|
|||
following: true,
|
||||
},
|
||||
last_message_sent_at: "2021-07-05T12:04:00.850Z",
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -105,6 +113,10 @@ export const chatChannels = {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
|
@ -120,6 +132,10 @@ export const chatChannels = {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
|
@ -135,6 +151,10 @@ export const chatChannels = {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
|
@ -150,6 +170,10 @@ export const chatChannels = {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
|
@ -165,6 +189,10 @@ export const chatChannels = {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
|
@ -180,6 +208,10 @@ export const chatChannels = {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
|
@ -195,9 +227,20 @@ export const chatChannels = {
|
|||
muted: false,
|
||||
following: true,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
direct_message_channels: directMessageChannels.mapBy("chat_channel"),
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const message0 = {
|
||||
|
|
|
@ -31,6 +31,10 @@ export default {
|
|||
name: "My category name",
|
||||
chatable: categoryChatableFabricator(),
|
||||
last_message_sent_at: "2021-11-08T21:26:05.710Z",
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
}),
|
||||
|
||||
chatChannelMessage: Fabricator(EmberObject, {
|
||||
|
@ -46,5 +50,9 @@ export default {
|
|||
status: "open",
|
||||
chatable: directChannelChatableFabricator(),
|
||||
last_message_sent_at: "2021-11-08T21:26:05.710Z",
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -39,9 +39,20 @@ acceptance("Discourse Chat | Unit | Service | chat", function (needs) {
|
|||
unread_mentions: 0,
|
||||
muted: false,
|
||||
},
|
||||
message_bus_last_ids: {
|
||||
new_mentions: 0,
|
||||
new_messages: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
direct_message_channels: [],
|
||||
message_bus_last_ids: {
|
||||
channel_metadata: 0,
|
||||
channel_edits: 0,
|
||||
channel_status: 0,
|
||||
new_channel: 0,
|
||||
user_tracking_state: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue