Class: Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Notification
- Includes:
- Diaspora::Socketable
- Defined in:
- app/models/notification.rb
Overview
Copyright © 2010, Diaspora Inc. This file is
licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
Direct Known Subclasses
Notifications::AlsoCommented, Notifications::CommentOnPost, Notifications::Liked, Notifications::Mentioned, Notifications::PrivateMessage, Notifications::RequestAccepted, Notifications::StartedSharing
Class Method Summary (collapse)
Instance Method Summary (collapse)
Methods included from Diaspora::Socketable
#socket_to_user, #unsocket_from_user
Class Method Details
+ (Object) for(recipient, opts = {})
14 15 16 |
# File 'app/models/notification.rb', line 14 def self.for(recipient, opts={}) self.where(opts.merge!(:recipient_id => recipient.id)).order('updated_at desc') end |
+ (Object) notify(recipient, target, actor)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/notification.rb', line 18 def self.notify(recipient, target, actor) if target.respond_to? :notification_type if note_type = target.notification_type(recipient, actor) if(target.is_a? Comment) || (target.is_a? Like) n = note_type.concatenate_or_create(recipient, target.post, actor, note_type) else n = note_type.make_notification(recipient, target, actor, note_type) end n.email_the_user(target, actor) if n n.socket_to_user(recipient, :actor => actor) if n n end end end |
Instance Method Details
- (Object) email_the_user(target, actor)
33 34 35 |
# File 'app/models/notification.rb', line 33 def email_the_user(target, actor) self.recipient.mail(self.mail_job, self.recipient_id, actor.id, target.id) end |
- (Object) mail_job
38 39 40 |
# File 'app/models/notification.rb', line 38 def mail_job raise NotImplementedError.new('Subclass this.') end |