chore: Replace content with outgoing_content in webhook data (#11829)
The API channels don't receive CSAT survey URLs in webhook payloads since `webhook_data` uses content instead of outgoing_content.
This commit is contained in:
@@ -168,7 +168,7 @@ class Message < ApplicationRecord
|
||||
additional_attributes: additional_attributes,
|
||||
content_attributes: content_attributes,
|
||||
content_type: content_type,
|
||||
content: content,
|
||||
content: outgoing_content,
|
||||
conversation: conversation.webhook_data,
|
||||
created_at: created_at,
|
||||
id: id,
|
||||
|
||||
@@ -267,6 +267,23 @@ RSpec.describe Message do
|
||||
message = create(:message)
|
||||
expect(message.webhook_data.key?(:attachments)).to be false
|
||||
end
|
||||
|
||||
it 'uses outgoing_content for webhook content' do
|
||||
message = create(:message, content: 'Test content')
|
||||
expect(message).to receive(:outgoing_content).and_return('Outgoing test content')
|
||||
|
||||
webhook_data = message.webhook_data
|
||||
expect(webhook_data[:content]).to eq('Outgoing test content')
|
||||
end
|
||||
|
||||
it 'includes CSAT survey link in webhook content for input_csat messages' do
|
||||
inbox = create(:inbox, channel: create(:channel_api))
|
||||
conversation = create(:conversation, inbox: inbox)
|
||||
message = create(:message, conversation: conversation, content_type: 'input_csat', content: 'Rate your experience')
|
||||
|
||||
expect(message.outgoing_content).to include('survey/responses/')
|
||||
expect(message.webhook_data[:content]).to include('survey/responses/')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when message is created' do
|
||||
|
||||
Reference in New Issue
Block a user