class Conversations::UnreadCounts::Notifier include Events::Types attr_reader :conversation, :changed_attributes def initialize(conversation, changed_attributes: nil) @conversation = conversation @changed_attributes = changed_attributes end def perform return false unless conversation.account.feature_enabled?('conversation_unread_counts') return false unless ::Conversations::UnreadCounts::Refresher.new(conversation, changed_attributes: changed_attributes).perform Rails.configuration.dispatcher.dispatch(CONVERSATION_UNREAD_COUNT_CHANGED, Time.zone.now, conversation: conversation) true end end