Feature: Twitter DM Integration (#451)
An initial version of twitter integration Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
24
app/services/twitter/send_reply_service.rb
Normal file
24
app/services/twitter/send_reply_service.rb
Normal 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
|
||||
Reference in New Issue
Block a user