c21c839dca
* move source id from contacts * Fix contactInbox model name * rubocop fix * Fix rspec
34 lines
629 B
Ruby
34 lines
629 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Integrations
|
|
module Facebook
|
|
class DeliveryStatus
|
|
def initialize(params)
|
|
@params = params
|
|
end
|
|
|
|
def perform
|
|
update_message_status
|
|
end
|
|
|
|
private
|
|
|
|
def sender_id
|
|
@params.sender['id']
|
|
end
|
|
|
|
def contact
|
|
::ContactInbox.find_by(source_id: sender_id).contact
|
|
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!
|
|
end
|
|
end
|
|
end
|
|
end
|