mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: Chat threads N1 (#22322)
Followup to 1526d1f97d4617b5de03db8b71cd02cb1802d49c This commit fixes an N1 for mentions/user status when querying chat threads. This only happened if any of the thread OMs had mentions.
This commit is contained in:
@ -124,6 +124,38 @@ RSpec.describe Chat::Api::ChannelThreadsController do
|
||||
)
|
||||
end
|
||||
|
||||
it "has preloaded chat mentions and users for the thread original message" do
|
||||
thread_1.original_message.update!(
|
||||
message: "@#{current_user.username} hello and @#{thread_2.original_message_user.username}!",
|
||||
)
|
||||
thread_1.original_message.rebake!
|
||||
thread_1.original_message.create_mentions
|
||||
|
||||
get "/chat/api/channels/#{public_channel.id}/threads"
|
||||
expect(response.status).to eq(200)
|
||||
expect(
|
||||
response.parsed_body["threads"]
|
||||
.find { |thread| thread["id"] == thread_1.id }
|
||||
.dig("original_message", "mentioned_users"),
|
||||
).to eq(
|
||||
[
|
||||
{
|
||||
"avatar_template" => User.system_avatar_template(current_user.username),
|
||||
"id" => current_user.id,
|
||||
"name" => current_user.name,
|
||||
"username" => current_user.username,
|
||||
},
|
||||
{
|
||||
"avatar_template" =>
|
||||
User.system_avatar_template(thread_2.original_message_user.username),
|
||||
"id" => thread_2.original_message_user.id,
|
||||
"name" => thread_2.original_message_user.name,
|
||||
"username" => thread_2.original_message_user.username,
|
||||
},
|
||||
],
|
||||
)
|
||||
end
|
||||
|
||||
context "when the channel is not accessible to the useer" do
|
||||
before do
|
||||
public_channel.update!(chatable: Fabricate(:private_category, group: Fabricate(:group)))
|
||||
|
Reference in New Issue
Block a user