mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 01:04:33 +08:00
PERF: Make chat mention notifications async. (#19666)
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
This commit is contained in:
21
plugins/chat/app/jobs/regular/send_message_notifications.rb
Normal file
21
plugins/chat/app/jobs/regular/send_message_notifications.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# 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
|
Reference in New Issue
Block a user