Merge branch 'develop' into feature/cw-7513

This commit is contained in:
Tanmay Deep Sharma
2026-07-13 14:36:26 +05:30
55 changed files with 1547 additions and 121 deletions
+2
View File
@@ -22,6 +22,8 @@
# index_assignment_policies_on_enabled (enabled)
#
class AssignmentPolicy < ApplicationRecord
DEFAULT_EXCLUDE_OLDER_THAN_HOURS = 168
belongs_to :account
has_many :inbox_assignment_policies, dependent: :destroy
has_many :inboxes, through: :inbox_assignment_policies
+10
View File
@@ -33,6 +33,7 @@ class Channel::Whatsapp < ApplicationRecord
validate :validate_provider_config
after_create :sync_templates
after_update_commit :log_credentials_transfer, if: :saved_change_to_provider_config?
before_destroy :teardown_webhooks
after_commit :setup_webhooks, on: :create, if: :should_auto_setup_webhooks?
@@ -129,6 +130,15 @@ class Channel::Whatsapp < ApplicationRecord
errors.add(:provider_config, 'Invalid Credentials') unless provider_service.validate_provider_config?
end
# Logs only credential changes, so config-only saves (e.g. calling toggles) stay silent.
def log_credentials_transfer
before, after = saved_change_to_provider_config
keys = %w[api_key phone_number_id business_account_id]
return if before.nil? || before.values_at(*keys) == after.values_at(*keys)
Rails.logger.info("[WHATSAPP_MANUAL_TRANSFER] success account_id=#{account_id} channel_id=#{id}")
end
def perform_webhook_setup
webhook_setup_service.perform
end