fix: Contact Inbox uniq index violation
This commit is contained in:
parent
83eee7df91
commit
dc4cc538c8
1 changed files with 3 additions and 2 deletions
|
@ -36,14 +36,15 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
|
|||
private
|
||||
|
||||
def contact
|
||||
@contact ||= @inbox.contact_inboxes.find_by(source_id: @sender_id)&.contact
|
||||
@contact = @inbox.contact_inboxes.find_by(source_id: @sender_id)&.contact
|
||||
end
|
||||
|
||||
def build_contact
|
||||
return if contact.present?
|
||||
|
||||
@contact = Contact.create!(contact_params.except(:remote_avatar_url))
|
||||
@contact_inbox = ContactInbox.find_or_create_by!(contact: contact, inbox: @inbox, source_id: @sender_id)
|
||||
@contact_inbox = ContactInbox.find_or_create_by!(inbox: @inbox, source_id: @sender_id)
|
||||
@contact_inbox.update(contact: contact) if @contact_inbox.present? && @contact.present?
|
||||
end
|
||||
|
||||
def build_message
|
||||
|
|
Loading…
Reference in a new issue