Change sender_id to contact_id in conversations (#167)

* change sender_id to contact_id in conversations

* Fix failing tests

* Fix seeds

* fix specs

* Fix issues in facebook messenger
This commit is contained in:
Sojan Jose
2019-10-21 00:40:18 +05:30
committed by GitHub
parent 2099dc01a6
commit ba8f055802
20 changed files with 294 additions and 309 deletions

View File

@@ -1,30 +1,34 @@
# frozen_string_literal: true
class Integrations::Facebook::DeliveryStatus
def initialize(params)
@params = params
end
module Integrations
module Facebook
class DeliveryStatus
def initialize(params)
@params = params
end
def perform
update_message_status
end
def perform
update_message_status
end
private
private
def sender_id
@params.sender['id']
end
def sender_id
@params.sender['id']
end
def contact_id
@contact ||= ::Contact.find_by(source_id: sender_id)
end
def contact
Contact.find_by(source_id: sender_id)
end
def conversation
@conversation ||= ::Conversation.find_by(sender_id: contact_id)
end
def conversation
@conversation ||= ::Conversation.find_by(contact_id: contact.id)
end
def update_message_status
conversation.user_last_seen_at = @params.at
conversation.save!
def update_message_status
conversation.user_last_seen_at = @params.at
conversation.save!
end
end
end
end