mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 01:34:13 +08:00
0a5f548635
As part of this move, we are also renaming `discourse-chat` to `chat`.
23 lines
681 B
Ruby
23 lines
681 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class ProcessChatMessage < ::Jobs::Base
|
|
def execute(args = {})
|
|
DistributedMutex.synchronize(
|
|
"process_chat_message_#{args[:chat_message_id]}",
|
|
validity: 10.minutes,
|
|
) do
|
|
chat_message = ChatMessage.find_by(id: args[:chat_message_id])
|
|
return if !chat_message
|
|
processor = Chat::ChatMessageProcessor.new(chat_message)
|
|
processor.run!
|
|
|
|
if args[:is_dirty] || processor.dirty?
|
|
chat_message.update(cooked: processor.html, cooked_version: ChatMessage::BAKED_VERSION)
|
|
ChatPublisher.publish_processed!(chat_message)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|