Welcome to mirror list, hosted at ThFree Co, Russian Federation.

notification_service.rb « services « app - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d356a021118e4421c018113ef6c48f84cc1f8676 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class NotificationService
  NOTIFICATION_TYPES = {
    Comment       => [Notifications::CommentOnPost, Notifications::AlsoCommented],
    Like          => [Notifications::Liked],
    StatusMessage => [Notifications::Mentioned],
    Conversation  => [Notifications::PrivateMessage],
    Message       => [Notifications::PrivateMessage],
    Reshare       => [Notifications::Reshared],
    Contact       => [Notifications::StartedSharing]
  }.freeze

  def notify(object, recipient_user_ids)
    notification_types(object).each {|type| type.notify(object, recipient_user_ids) }
  end

  private

  def notification_types(object)
    NOTIFICATION_TYPES.fetch(object.class, [])
  end
end