Class: Thredded::NotifyPrivateTopicUsers

Inherits:
Object
  • Object
show all
Defined in:
app/commands/thredded/notify_private_topic_users.rb

Instance Method Summary collapse

Constructor Details

#initialize(private_post) ⇒ NotifyPrivateTopicUsers

Returns a new instance of NotifyPrivateTopicUsers.



4
5
6
7
# File 'app/commands/thredded/notify_private_topic_users.rb', line 4

def initialize(private_post)
  @post = private_post
  @private_topic = private_post.postable
end

Instance Method Details

#private_topic_recipientsObject



20
21
22
23
24
25
# File 'app/commands/thredded/notify_private_topic_users.rb', line 20

def private_topic_recipients
  members = private_topic.users - [post.user]
  members = exclude_those_opting_out_of_message_notifications(members)
  members = exclude_previously_notified(members)
  members
end

#runObject



9
10
11
12
13
14
15
16
17
18
# File 'app/commands/thredded/notify_private_topic_users.rb', line 9

def run
  members = private_topic_recipients

  return unless members.present?
  user_emails = members.map(&:email)
  PrivateTopicMailer
    .message_notification(private_topic.id, user_emails)
    .deliver_later
  mark_notified(members)
end