Fix: Creating contacts for already outgoing/echo messages (#4668)
Check if the Instagram contact is already present in the system before throwing the exception. Fixes: #4666
This commit is contained in:
@@ -22,7 +22,7 @@ class Instagram::MessageText < Instagram::WebhooksBaseService
|
|||||||
|
|
||||||
return unsend_message if message_is_deleted?
|
return unsend_message if message_is_deleted?
|
||||||
|
|
||||||
ensure_contact(contact_id)
|
ensure_contact(contact_id) if contacts_first_message?(contact_id)
|
||||||
|
|
||||||
create_message
|
create_message
|
||||||
end
|
end
|
||||||
@@ -36,7 +36,7 @@ class Instagram::MessageText < Instagram::WebhooksBaseService
|
|||||||
rescue Koala::Facebook::AuthenticationError
|
rescue Koala::Facebook::AuthenticationError
|
||||||
@inbox.channel.authorization_error!
|
@inbox.channel.authorization_error!
|
||||||
raise
|
raise
|
||||||
rescue StandardError => e
|
rescue StandardError, Koala::Facebook::ClientError => e
|
||||||
result = {}
|
result = {}
|
||||||
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
|
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
|
||||||
end
|
end
|
||||||
@@ -52,6 +52,10 @@ class Instagram::MessageText < Instagram::WebhooksBaseService
|
|||||||
@messaging[:message][:is_deleted].present?
|
@messaging[:message][:is_deleted].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def contacts_first_message?(ig_scope_id)
|
||||||
|
@inbox.contact_inboxes.where(source_id: ig_scope_id).empty? && @inbox.channel.instagram_id.present?
|
||||||
|
end
|
||||||
|
|
||||||
def unsend_message
|
def unsend_message
|
||||||
message_to_delete = @inbox.messages.find_by(
|
message_to_delete = @inbox.messages.find_by(
|
||||||
source_id: @messaging[:message][:mid]
|
source_id: @messaging[:message][:mid]
|
||||||
|
|||||||
Reference in New Issue
Block a user