Sha256: 868b0989deb899d96082b311d74254968eacf4ae88b398b2a4177ed9754b5713
Contents?: true
Size: 937 Bytes
Versions: 10
Compression:
Stored size: 937 Bytes
Contents
# frozen_string_literal: true module Thredded class NotifyPrivateTopicUsers def initialize(private_post) @post = private_post @private_topic = private_post.postable end 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 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 private attr_reader :post, :private_topic def only_those_with_this_notifier_enabled(users, notifier) users.select do |user| NotificationsForPrivateTopics .detect_or_default(user.thredded_notifications_for_private_topics, notifier).enabled? end end end end
Version data entries
10 entries across 10 versions & 1 rubygems