Class: Thredded::NotifyPrivateTopicUsers
- Inherits:
-
Object
- Object
- Thredded::NotifyPrivateTopicUsers
- Defined in:
- app/commands/thredded/notify_private_topic_users.rb
Instance Method Summary collapse
-
#initialize(private_post) ⇒ NotifyPrivateTopicUsers
constructor
A new instance of NotifyPrivateTopicUsers.
- #run ⇒ Object
- #targeted_users(notifier) ⇒ Object
Constructor Details
#initialize(private_post) ⇒ NotifyPrivateTopicUsers
Returns a new instance of NotifyPrivateTopicUsers.
5 6 7 8 |
# File 'app/commands/thredded/notify_private_topic_users.rb', line 5 def initialize(private_post) @post = private_post @private_topic = private_post.postable end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 |
# File 'app/commands/thredded/notify_private_topic_users.rb', line 10 def run Thredded.notifiers.each do |notifier| notifiable_users = targeted_users(notifier) notifier.new_private_post(@post, notifiable_users) if notifiable_users.present? end end |
#targeted_users(notifier) ⇒ Object
17 18 19 20 21 |
# File 'app/commands/thredded/notify_private_topic_users.rb', line 17 def targeted_users(notifier) users = private_topic.users.includes(:thredded_notifications_for_private_topics) - [post.user] users = only_those_with_this_notifier_enabled(users, notifier) users end |