mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
DEV: allows to disable strip_whitespaces in messages (#26848)
The TextCleaner step has been moved from chat message’s validation to create_message/update_message services. It allows us to easily tweak part of its behavior depending on the needs. For example we will now disable strip_whitespaces by default when streaming messages as we want to keep newlines and spaces at the end of the message.
This commit is contained in:
@ -37,7 +37,7 @@ module ChatSDK
|
||||
#
|
||||
# @see #create
|
||||
def self.create_with_stream(**params, &block)
|
||||
self.create(**params, streaming: true, &block)
|
||||
self.create(**params, streaming: true, strip_whitespaces: false, &block)
|
||||
end
|
||||
|
||||
# Streams to a specific chat message.
|
||||
@ -114,6 +114,7 @@ module ChatSDK
|
||||
streaming: false,
|
||||
enforce_membership: false,
|
||||
force_thread: false,
|
||||
strip_whitespaces: true,
|
||||
&block
|
||||
)
|
||||
message =
|
||||
@ -128,6 +129,7 @@ module ChatSDK
|
||||
streaming: streaming,
|
||||
enforce_membership: enforce_membership,
|
||||
force_thread: force_thread,
|
||||
strip_whitespaces: strip_whitespaces,
|
||||
) do
|
||||
on_model_not_found(:channel) { raise "Couldn't find channel with id: `#{channel_id}`" }
|
||||
on_model_not_found(:channel_membership) do
|
||||
@ -179,6 +181,7 @@ module ChatSDK
|
||||
message: self.message.message + raw,
|
||||
guardian: self.guardian,
|
||||
streaming: true,
|
||||
strip_whitespaces: false,
|
||||
) { on_failure { raise "Unexpected error" } }
|
||||
|
||||
self.message
|
||||
|
Reference in New Issue
Block a user