mirror of
https://github.com/discourse/discourse.git
synced 2024-12-17 09:43:49 +08:00
2f61d26e3d
This PR removes the limit added to max_users_notified_per_group_mention during #19034 and improve the performance when expanding mentions for large channel or groups by removing some N+1 queries and making the whole process async. * Fully async chat message notifications * Remove mention setting limit and get rid of N+1 queries
22 lines
573 B
Ruby
22 lines
573 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class SendMessageNotifications < ::Jobs::Base
|
|
def execute(args)
|
|
reason = args[:reason]
|
|
valid_reasons = %w[new edit]
|
|
return unless valid_reasons.include?(reason)
|
|
|
|
return if (timestamp = args[:timestamp]).blank?
|
|
|
|
return if (message = ChatMessage.find_by(id: args[:chat_message_id])).nil?
|
|
|
|
if reason == "new"
|
|
Chat::ChatNotifier.new(message, timestamp).notify_new
|
|
elsif reason == "edit"
|
|
Chat::ChatNotifier.new(message, timestamp).notify_edit
|
|
end
|
|
end
|
|
end
|
|
end
|