2019-10-16 06:52:30 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-10-20 19:10:18 +00:00
|
|
|
module Integrations
|
|
|
|
module Facebook
|
|
|
|
class DeliveryStatus
|
|
|
|
def initialize(params)
|
|
|
|
@params = params
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-20 19:10:18 +00:00
|
|
|
def perform
|
|
|
|
update_message_status
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-20 19:10:18 +00:00
|
|
|
private
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-20 19:10:18 +00:00
|
|
|
def sender_id
|
|
|
|
@params.sender['id']
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-20 19:10:18 +00:00
|
|
|
def contact
|
|
|
|
Contact.find_by(source_id: sender_id)
|
|
|
|
end
|
2019-08-31 06:22:09 +00:00
|
|
|
|
2019-10-20 19:10:18 +00:00
|
|
|
def conversation
|
|
|
|
@conversation ||= ::Conversation.find_by(contact_id: contact.id)
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-20 19:10:18 +00:00
|
|
|
def update_message_status
|
|
|
|
conversation.user_last_seen_at = @params.at
|
|
|
|
conversation.save!
|
|
|
|
end
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
end
|