diff --git a/Gemfile.lock b/Gemfile.lock index 5b14d5b5e..686c3a37b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/jobs/webhooks/instagram_events_job.rb b/app/jobs/webhooks/instagram_events_job.rb index f0801fbc8..0f78c6277 100644 --- a/app/jobs/webhooks/instagram_events_job.rb +++ b/app/jobs/webhooks/instagram_events_job.rb @@ -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 diff --git a/app/services/instagram/message_text.rb b/app/services/instagram/message_text.rb index abcbe2d60..6ce8ec02b 100644 --- a/app/services/instagram/message_text.rb +++ b/app/services/instagram/message_text.rb @@ -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?