iachat/app/services/twitter/send_reply_service.rb
Pranav Raj S a9c304f1ef
Feature: Twitter DM Integration (#451)
An initial version of twitter integration

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2020-02-03 00:54:00 +05:45

25 lines
553 B
Ruby

class Twitter::SendReplyService
pattr_initialize [:message!]
def perform
return if message.private
return if inbox.channel.class.to_s != 'Channel::TwitterProfile'
return unless outgoing_message_from_chatwoot?
$twitter.send_direct_message(
recipient_id: contact_inbox.source_id,
message: message.content
)
end
private
def outgoing_message_from_chatwoot?
message.outgoing?
end
delegate :contact_inbox, to: :conversation
delegate :conversation, to: :message
delegate :inbox, to: :conversation
end