diff --git a/app/builders/messages/facebook/message_builder.rb b/app/builders/messages/facebook/message_builder.rb index 9f670602a..33f826b48 100644 --- a/app/builders/messages/facebook/message_builder.rb +++ b/app/builders/messages/facebook/message_builder.rb @@ -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