mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FIX: Do not duplicate check when editing chat message to remove uploads (#19432)
There is no need to duplicate check chat messages when they are being edited but not having their message text changed. This was leading to a validation error when adding/removing an upload but not changing the message text.
This commit is contained in:
@ -37,7 +37,10 @@ class ChatMessage < ActiveRecord::Base
|
||||
|
||||
def validate_message(has_uploads:)
|
||||
WatchedWordsValidator.new(attributes: [:message]).validate(self)
|
||||
Chat::DuplicateMessageValidator.new(self).validate
|
||||
|
||||
if self.new_record? || self.changed.include?("message")
|
||||
Chat::DuplicateMessageValidator.new(self).validate
|
||||
end
|
||||
|
||||
if !has_uploads && message_too_short?
|
||||
self.errors.add(
|
||||
@ -52,10 +55,7 @@ class ChatMessage < ActiveRecord::Base
|
||||
if message_too_long?
|
||||
self.errors.add(
|
||||
:base,
|
||||
I18n.t(
|
||||
"chat.errors.message_too_long",
|
||||
maximum: SiteSetting.chat_maximum_message_length,
|
||||
),
|
||||
I18n.t("chat.errors.message_too_long", maximum: SiteSetting.chat_maximum_message_length),
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -184,7 +184,7 @@ class ChatMessage < ActiveRecord::Base
|
||||
markdown_it_rules: MARKDOWN_IT_RULES,
|
||||
force_quote_link: true,
|
||||
user_id: opts[:user_id],
|
||||
hashtag_context: "chat-composer"
|
||||
hashtag_context: "chat-composer",
|
||||
)
|
||||
|
||||
result =
|
||||
|
Reference in New Issue
Block a user