fix(zapi): zapi args in message content attributes (#154)

* fix(zapi): zapi args in message content attributes

* fix(zapi): add zapi_args method and integrate into message_params
This commit is contained in:
Gabriel Jablonski 2025-11-24 15:02:27 -03:00 committed by GitHub
parent 4cdbef2ce2
commit fca269c1d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,7 @@ class Messages::MessageBuilder # rubocop:disable Metrics/ClassLength
attr_reader :message attr_reader :message
def initialize(user, conversation, params) # rubocop:disable Metrics/CyclomaticComplexity def initialize(user, conversation, params) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
@params = params @params = params
@private = params[:private] || false @private = params[:private] || false
@conversation = conversation @conversation = conversation
@ -20,6 +20,7 @@ class Messages::MessageBuilder # rubocop:disable Metrics/ClassLength
@in_reply_to = content_attributes&.dig(:in_reply_to) @in_reply_to = content_attributes&.dig(:in_reply_to)
@is_reaction = content_attributes&.dig(:is_reaction) @is_reaction = content_attributes&.dig(:is_reaction)
@items = content_attributes&.dig(:items) @items = content_attributes&.dig(:items)
@zapi_args = content_attributes&.dig(:zapi_args)
end end
def perform def perform
@ -147,6 +148,10 @@ class Messages::MessageBuilder # rubocop:disable Metrics/ClassLength
AgentBot.where(account_id: [nil, @conversation.account.id]).find_by(id: @params[:sender_id]) AgentBot.where(account_id: [nil, @conversation.account.id]).find_by(id: @params[:sender_id])
end end
def zapi_args
@zapi_args.present? ? { zapi_args: @zapi_args } : {}
end
def message_params def message_params
{ {
account_id: @conversation.account_id, account_id: @conversation.account_id,
@ -161,7 +166,7 @@ class Messages::MessageBuilder # rubocop:disable Metrics/ClassLength
is_reaction: @is_reaction, is_reaction: @is_reaction,
echo_id: @params[:echo_id], echo_id: @params[:echo_id],
source_id: @params[:source_id] source_id: @params[:source_id]
}.merge(external_created_at).merge(automation_rule_id).merge(campaign_id).merge(template_params) }.merge(external_created_at).merge(automation_rule_id).merge(campaign_id).merge(template_params).merge(zapi_args)
end end
def email_inbox? def email_inbox?