Skip to content

Commit

Permalink
FIX: add excerpt fallback for chat message replies (#26834)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbattersby committed May 1, 2024
1 parent acdaa3b commit c1f6ec5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/chat/app/serializers/chat/in_reply_to_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ class InReplyToSerializer < ApplicationSerializer
def user
object.user || Chat::NullUser.new
end

def excerpt
object.excerpt || object.build_excerpt
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@
it "censors words" do
expect(serializer.as_json[:excerpt]).to eq("ok ■■■■■")
end

it "builds an excerpt for replied to message if it doesn’t have one" do
message.update!(excerpt: nil)
expect(serializer.as_json[:excerpt]).to eq(message.build_excerpt)
end
end
end

1 comment on commit c1f6ec5

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/chat-replies-missing-excerpt/305991/6

Please sign in to comment.