FIX: webhook should touch channel’s last_message_sent_at (#19342)
This commit is contained in:
parent
9c8043a4d2
commit
179d15d90e
|
@ -110,7 +110,6 @@ class Chat::ChatController < Chat::ChatBaseController
|
||||||
|
|
||||||
return render_json_error(chat_message_creator.error) if chat_message_creator.failed?
|
return render_json_error(chat_message_creator.error) if chat_message_creator.failed?
|
||||||
|
|
||||||
@chat_channel.touch(:last_message_sent_at)
|
|
||||||
@user_chat_channel_membership.update(last_read_message_id: chat_message_creator.chat_message.id)
|
@user_chat_channel_membership.update(last_read_message_id: chat_message_creator.chat_message.id)
|
||||||
|
|
||||||
if @chat_channel.direct_message_channel?
|
if @chat_channel.direct_message_channel?
|
||||||
|
|
|
@ -53,6 +53,7 @@ class Chat::ChatMessageCreator
|
||||||
chat_message: @chat_message,
|
chat_message: @chat_message,
|
||||||
timestamp: @chat_message.created_at,
|
timestamp: @chat_message.created_at,
|
||||||
)
|
)
|
||||||
|
@chat_channel.touch(:last_message_sent_at)
|
||||||
DiscourseEvent.trigger(:chat_message_created, @chat_message, @chat_channel, @user)
|
DiscourseEvent.trigger(:chat_message_created, @chat_message, @chat_channel, @user)
|
||||||
rescue => error
|
rescue => error
|
||||||
@error = error
|
@error = error
|
||||||
|
|
|
@ -112,6 +112,18 @@ describe Chat::ChatMessageCreator do
|
||||||
}.to change { ChatMessage.count }.by(1)
|
}.to change { ChatMessage.count }.by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "updates the channel’s last message date" do
|
||||||
|
previous_last_message_sent_at = public_chat_channel.last_message_sent_at
|
||||||
|
|
||||||
|
Chat::ChatMessageCreator.create(
|
||||||
|
chat_channel: public_chat_channel,
|
||||||
|
user: user1,
|
||||||
|
content: "this is a message",
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(previous_last_message_sent_at).to be < public_chat_channel.reload.last_message_sent_at
|
||||||
|
end
|
||||||
|
|
||||||
it "sets the last_editor_id to the user who created the message" do
|
it "sets the last_editor_id to the user who created the message" do
|
||||||
message =
|
message =
|
||||||
Chat::ChatMessageCreator.create(
|
Chat::ChatMessageCreator.create(
|
||||||
|
|
Loading…
Reference in New Issue