fix: ensure contact_inbox if contact exists(#5667)

- Fixing Instagram issue for existing contacts in the inbox
This commit is contained in:
Tejaswini Chile 2022-10-20 01:26:39 +05:30 committed by GitHub
parent f740727177
commit 0343acdb7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -427,14 +427,14 @@ GEM
netrc (0.11.0)
newrelic_rpm (8.9.0)
nio4r (2.5.8)
nokogiri (1.13.7)
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.7-arm64-darwin)
nokogiri (1.13.9-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.7-x86_64-darwin)
nokogiri (1.13.9-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.7-x86_64-linux)
nokogiri (1.13.9-x86_64-linux)
racc (~> 1.4)
oauth (0.5.10)
orm_adapter (0.5.0)
@ -808,4 +808,4 @@ RUBY VERSION
ruby 3.0.4p208
BUNDLED WITH
2.3.18
2.3.16

View file

@ -13,6 +13,7 @@ class Webhooks::InstagramEventsJob < ApplicationJob
@entries = entries
@entries.each do |entry|
entry = entry.with_indifferent_access
entry[:messaging].each do |messaging|
send(@event_name, messaging) if event_name(messaging)
end

View file

@ -53,8 +53,10 @@ class Instagram::MessageText < Instagram::WebhooksBaseService
@messaging[:message][:is_deleted].present?
end
# if contact was present before find out contact_inbox to create message
def contacts_first_message?(ig_scope_id)
@inbox.contact_inboxes.where(source_id: ig_scope_id).empty? && @inbox.channel.instagram_id.present?
@contact_inbox = @inbox.contact_inboxes.where(source_id: ig_scope_id).last
@contact_inbox.blank? && @inbox.channel.instagram_id.present?
end
def sent_via_test_webhook?