feat: Add job to remove stale contact inboxes (#8096)
This commit is contained in:
@@ -33,6 +33,13 @@ class ContactInbox < ApplicationRecord
|
||||
|
||||
has_many :conversations, dependent: :destroy_async
|
||||
|
||||
# contact_inboxes that are not associated with any conversation
|
||||
scope :stale_without_conversations, lambda { |time_period|
|
||||
left_joins(:conversations)
|
||||
.where('contact_inboxes.created_at < ?', time_period)
|
||||
.where(conversations: { contact_id: nil })
|
||||
}
|
||||
|
||||
def webhook_data
|
||||
{
|
||||
id: id,
|
||||
|
||||
Reference in New Issue
Block a user