Feature: Twitter DM Integration (#451)

An initial version of twitter integration

Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-02-03 00:39:00 +05:30
committed by GitHub
parent a287c86bc4
commit a9c304f1ef
20 changed files with 406 additions and 49 deletions

View File

@@ -0,0 +1,24 @@
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