feat: Ability to block contacts permanently (#8922)

Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
Sojan Jose
2024-02-22 03:48:42 +05:30
committed by GitHub
parent c031cb19d2
commit ae4c8d818f
10 changed files with 63 additions and 28 deletions

View File

@@ -61,6 +61,7 @@ class Conversation < ApplicationRecord
validates :account_id, presence: true
validates :inbox_id, presence: true
validates :contact_id, presence: true
before_validation :validate_additional_attributes
validates :additional_attributes, jsonb_attributes_length: true
validates :custom_attributes, jsonb_attributes_length: true
@@ -103,7 +104,7 @@ class Conversation < ApplicationRecord
has_many :attachments, through: :messages
before_save :ensure_snooze_until_reset
before_create :mark_conversation_pending_if_bot
before_create :determine_conversation_status
before_create :ensure_waiting_since
after_update_commit :execute_after_update_commit_callbacks
@@ -226,7 +227,9 @@ class Conversation < ApplicationRecord
self.additional_attributes = {} unless additional_attributes.is_a?(Hash)
end
def mark_conversation_pending_if_bot
def determine_conversation_status
self.status = :resolved and return if contact.blocked?
# Message template hooks aren't executed for conversations from campaigns
# So making these conversations open for agent visibility
return if campaign.present?