Fix notifications for private messages between local users, fixes #2321

This commit is contained in:
Jason Robinson 2012-11-10 23:09:16 +02:00
parent 7517c29ed0
commit 6cf6f1dd7d
2 changed files with 2 additions and 5 deletions

View file

@ -59,13 +59,10 @@ class Message < ActiveRecord::Base
self.conversation = parent self.conversation = parent
end 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 if vis = ConversationVisibility.where(:conversation_id => self.conversation_id, :person_id => user.person.id).first
vis.unread += 1 vis.unread += 1
vis.save 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
end end

View file

@ -8,7 +8,7 @@ class Notifications::PrivateMessage < Notification
def self.make_notification(recipient, target, actor, notification_type) def self.make_notification(recipient, target, actor, notification_type)
n = notification_type.new(:target => target, n = notification_type.new(:target => target,
:recipient_id => recipient.id) :recipient_id => recipient.id)
target.increase_unread(recipient)
n.actors << actor n.actors << actor
n n
end end