feat: Ability to reply to specific tweets (#1117)

Ability to choose a specific tweet to reply to

Fixes #982
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
Sojan Jose
2020-08-11 09:57:42 +05:30
committed by GitHub
parent a6a62d92bf
commit 4216d63311
23 changed files with 290 additions and 38 deletions

View File

@@ -29,7 +29,7 @@ class Twitter::SendOnTwitterService < Base::SendOnChannelService
end
def screen_name
"@#{additional_attributes ? additional_attributes['screen_name'] : ''} "
"@#{reply_to_message.sender&.additional_attributes.try(:[], 'screen_name') || ''}"
end
def send_direct_message
@@ -39,10 +39,18 @@ class Twitter::SendOnTwitterService < Base::SendOnChannelService
)
end
def reply_to_message
@reply_to_message ||= if message.in_reply_to
conversation.messages.find(message.in_reply_to)
else
conversation.messages.incoming.last
end
end
def send_tweet_reply
response = twitter_client.send_tweet_reply(
reply_to_tweet_id: conversation.additional_attributes['tweet_id'],
tweet: screen_name + message.content
reply_to_tweet_id: reply_to_message.source_id,
tweet: "#{screen_name} #{message.content}"
)
if response.status == '200'
tweet_data = response.body