mirror of
https://github.com/discourse/discourse.git
synced 2025-06-25 01:30:17 +08:00
FEATURE: Copy thread messages when copying thread OP (#32139)
This introduces functionality to chat transcripts. If you select _only_ a thread's OP and press the Copy button, we will now copy the OP plus all of the thread's replies into the transcript. This is being done to make it easier to copy all the context of a thread easily. The old way of selecting only some messages inside a thread still works too. This commit also unskips and refactors some transcript specs.
This commit is contained in:
@ -166,9 +166,17 @@ module Chat
|
||||
previous_message = nil
|
||||
rendered_markdown = []
|
||||
rendered_thread_markdown = []
|
||||
all_messages_same_user = messages.count(:user_id) == 1
|
||||
threading_enabled = @channel.threading_enabled?
|
||||
thread_id = threading_enabled ? messages.first.thread_id : nil
|
||||
thread = Chat::Thread.find_by(id: thread_id) if thread_id.present? && threading_enabled
|
||||
|
||||
# We are getting only the OP of the thread, let's expand it to
|
||||
# include all the replies for the thread.
|
||||
if messages.count == 1 && thread&.original_message_id == messages.first.id
|
||||
@messages = [messages.first] + messages.first.thread.replies
|
||||
end
|
||||
|
||||
all_messages_same_user = messages.map(&:user_id).uniq.count == 1
|
||||
|
||||
open_bbcode_tag =
|
||||
TranscriptBBCode.new(
|
||||
|
Reference in New Issue
Block a user