feat: add external_created_at to message creation and update specs for provider callback
This commit is contained in:
parent
9a4c5058f3
commit
248d6c23b3
@ -194,6 +194,7 @@ class Whatsapp::IncomingMessageBaseService # rubocop:disable Metrics/ClassLength
|
||||
def create_message(message, source_id: nil)
|
||||
content_attrs = outgoing_echo ? { external_echo: true } : {}
|
||||
content_attrs[:in_reply_to_external_id] = @in_reply_to_external_id if @in_reply_to_external_id.present?
|
||||
content_attrs[:external_created_at] = message[:timestamp].to_i
|
||||
|
||||
@message = @conversation.messages.build(
|
||||
content: message_content(message),
|
||||
@ -204,8 +205,7 @@ class Whatsapp::IncomingMessageBaseService # rubocop:disable Metrics/ClassLength
|
||||
status: outgoing_echo ? :delivered : :sent,
|
||||
sender: outgoing_echo ? nil : @contact,
|
||||
source_id: (source_id || message[:id]).to_s,
|
||||
content_attributes: content_attrs,
|
||||
external_created_at: message[:timestamp].to_i
|
||||
content_attributes: content_attrs
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@ -489,6 +489,11 @@ RSpec.describe Channel::Whatsapp do
|
||||
context 'when provider does not implement the method' do
|
||||
let(:channel) { create(:channel_whatsapp, provider: 'whatsapp_cloud', validate_provider_config: false, sync_templates: false) }
|
||||
|
||||
before do
|
||||
stub_request(:delete, "https://graph.facebook.com/v22.0/#{channel.provider_config['business_account_id']}/subscribed_apps")
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
end
|
||||
|
||||
it 'does not invoke callback' do
|
||||
expect(channel).not_to receive(:disconnect_channel_provider)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user