From 6cf6f1dd7da9e1e1311d0c366a682bfb3334e712 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Sat, 10 Nov 2012 23:09:16 +0200 Subject: [PATCH] Fix notifications for private messages between local users, fixes #2321 --- app/models/message.rb | 5 +---- app/models/notifications/private_message.rb | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index dec6fb492..f4f75bffe 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -59,13 +59,10 @@ class Message < ActiveRecord::Base self.conversation = parent end - def after_receive(user, person) + def increase_unread(user) if vis = ConversationVisibility.where(:conversation_id => self.conversation_id, :person_id => user.person.id).first vis.unread += 1 vis.save - self - else - raise NotVisibleError.new("User #{user.id} with person #{user.person.id} is not allowed to see conversation #{conversation.id}!") end end diff --git a/app/models/notifications/private_message.rb b/app/models/notifications/private_message.rb index 6a064ffb9..27f0197d9 100644 --- a/app/models/notifications/private_message.rb +++ b/app/models/notifications/private_message.rb @@ -8,7 +8,7 @@ class Notifications::PrivateMessage < Notification def self.make_notification(recipient, target, actor, notification_type) n = notification_type.new(:target => target, :recipient_id => recipient.id) - + target.increase_unread(recipient) n.actors << actor n end