Files
Sony MathewandGitHub 66cfb26c77 feat: Add unread count filters feature flag (1/6) (#14885)
## Description

Adds the account-level `unread_count_for_filters` feature flag as the
dark-launch gate for filtered sidebar unread counts. This reuses the
deprecated `quoted_email_reply` flag slot, resets the reused bit for
existing accounts, and removes stale defaults so new accounts do not
reference the old flag.

This also adds the feature where we are now calculating the unread counts for built in filters like mentions, participating and unattended along with unread count for saved filters/folders.

Closes
[CW-7262](https://linear.app/chatwoot/issue/CW-7262/unread-counts-for-filters-folders)

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
- [ ] This change requires a documentation update
2026-07-08 23:50:40 +05:30

30 lines
953 B
Ruby

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 dispatch_unread_count_changed if ::Conversations::UnreadCounts::Refresher.new(conversation, changed_attributes: changed_attributes).perform
return false unless conversation.account.feature_enabled?(filtered_count_feature_flag)
dispatch_unread_count_changed
end
private
def dispatch_unread_count_changed
Rails.configuration.dispatcher.dispatch(CONVERSATION_UNREAD_COUNT_CHANGED, Time.zone.now, conversation: conversation)
true
end
def filtered_count_feature_flag
::Conversations::UnreadCounts::FilteredCountInvalidator::FEATURE_FLAG
end
end