Skip to content
Extraits de code Groupes Projets
Valider ae96b4bf rédigé par Benjamin Neff's avatar Benjamin Neff
Parcourir les fichiers

refactor message notifications

all visibilities are already in the conversation, so we can send
all notifications at once.
parent 9b0e40bf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -8,22 +8,21 @@ module Notifications ...@@ -8,22 +8,21 @@ module Notifications
"notifications.private_message" "notifications.private_message"
end end
def self.notify(object, recipient_user_ids) def self.notify(object, _recipient_user_ids)
case object case object
when Conversation when Conversation
object.messages.each do |message| object.messages.each {|message| notify_message(message) }
recipient_ids = recipient_user_ids - [message.author.owner_id]
User.where(id: recipient_ids).find_each {|recipient| notify_message(message, recipient) }
end
when Message when Message
recipients = object.conversation.participants.select(&:local?) - [object.author] notify_message(object)
recipients.each {|recipient| notify_message(object, recipient.owner) }
end end
end end
def self.notify_message(message, recipient) def self.notify_message(message)
message.increase_unread(recipient) recipient_ids = message.conversation.participants.local.where.not(id: message.author_id).pluck(:owner_id)
new(recipient: recipient).email_the_user(message, message.author) User.where(id: recipient_ids).find_each do |recipient|
message.increase_unread(recipient)
new(recipient: recipient).email_the_user(message, message.author)
end
end end
private_class_method :notify_message private_class_method :notify_message
end end
......
...@@ -37,7 +37,7 @@ module Diaspora ...@@ -37,7 +37,7 @@ module Diaspora
def self.conversation(entity) def self.conversation(entity)
author = author_of(entity) author = author_of(entity)
try_load_existing_guid(Conversation, entity.guid, author) do ignore_existing_guid(Conversation, entity.guid, author) do
Conversation.new( Conversation.new(
author: author, author: author,
guid: entity.guid, guid: entity.guid,
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter