fix: contact is not available for inaccessible sender (#5509)

Fixes: #5508

We can not read contact information because of this error, as the messages echo when the sender sends messages to contacts. We don't have the user's consent until and unless they send messages to us.

So after this result, information about the contact is empty, and we are trying to create a contact inbox for the same, and the error appears.

type: OAuthException, code: 230, message: (#230) User consent is required to access user profile, x-fb-trace-id: AaitxF/whwY [HTTP 403] (Koala::Facebook::ClientError)
This commit is contained in:
Tejaswini Chile
2022-09-29 01:20:23 +05:30
committed by GitHub
parent 83eee7df91
commit fcb9a9ab0c
3 changed files with 57 additions and 6 deletions

View File

@@ -42,7 +42,7 @@ class Instagram::MessageText < Instagram::WebhooksBaseService
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
end
find_or_create_contact(result)
find_or_create_contact(result) if result.present?
end
def agent_message_via_echo?
@@ -71,6 +71,8 @@ class Instagram::MessageText < Instagram::WebhooksBaseService
end
def create_message
return unless @contact_inbox
Messages::Instagram::MessageBuilder.new(@messaging, @inbox, outgoing_echo: agent_message_via_echo?).perform
end