|
@@ -51,10 +51,9 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
|
|
# fill article with tweet info
|
|
# fill article with tweet info
|
|
|
|
|
|
# direct message
|
|
# direct message
|
|
- tweet_id = nil
|
|
|
|
if tweet.is_a?(Hash)
|
|
if tweet.is_a?(Hash)
|
|
tweet_type = 'DirectMessage'
|
|
tweet_type = 'DirectMessage'
|
|
- tweet_id = tweet[:event][:id].to_s
|
|
|
|
|
|
+ article.message_id = tweet[:event][:id].to_s
|
|
if tweet[:event] && tweet[:event][:type] == 'message_create'
|
|
if tweet[:event] && tweet[:event][:type] == 'message_create'
|
|
#article.from = "@#{tweet.sender.screen_name}"
|
|
#article.from = "@#{tweet.sender.screen_name}"
|
|
#article.to = "@#{tweet.recipient.screen_name}"
|
|
#article.to = "@#{tweet.recipient.screen_name}"
|
|
@@ -63,12 +62,19 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
|
|
recipient_id: tweet[:event][:message_create][:target][:recipient_id],
|
|
recipient_id: tweet[:event][:message_create][:target][:recipient_id],
|
|
sender_id: tweet[:event][:message_create][:sender_id],
|
|
sender_id: tweet[:event][:message_create][:sender_id],
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ article.preferences['links'] = [
|
|
|
|
+ {
|
|
|
|
+ url: "https://twitter.com/messages/#{article.preferences[:twitter][:recipient_id]}-#{article.preferences[:twitter][:sender_id]}",
|
|
|
|
+ target: '_blank',
|
|
|
|
+ name: 'on Twitter',
|
|
|
|
+ },
|
|
|
|
+ ]
|
|
end
|
|
end
|
|
|
|
|
|
# regular tweet
|
|
# regular tweet
|
|
elsif tweet.class == Twitter::Tweet
|
|
elsif tweet.class == Twitter::Tweet
|
|
tweet_type = 'Tweet'
|
|
tweet_type = 'Tweet'
|
|
- tweet_id = tweet.id.to_s
|
|
|
|
article.from = "@#{tweet.user.screen_name}"
|
|
article.from = "@#{tweet.user.screen_name}"
|
|
if tweet.user_mentions
|
|
if tweet.user_mentions
|
|
to = ''
|
|
to = ''
|
|
@@ -95,6 +101,15 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
|
|
created_at: tweet.created_at,
|
|
created_at: tweet.created_at,
|
|
)
|
|
)
|
|
end
|
|
end
|
|
|
|
+
|
|
|
|
+ article.message_id = tweet.id.to_s
|
|
|
|
+ article.preferences['links'] = [
|
|
|
|
+ {
|
|
|
|
+ url: "https://twitter.com/statuses/#{tweet.id}",
|
|
|
|
+ target: '_blank',
|
|
|
|
+ name: 'on Twitter',
|
|
|
|
+ },
|
|
|
|
+ ]
|
|
else
|
|
else
|
|
raise "Unknown tweet type '#{tweet.class}'"
|
|
raise "Unknown tweet type '#{tweet.class}'"
|
|
end
|
|
end
|
|
@@ -104,15 +119,6 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
|
|
article.preferences['delivery_status'] = 'success'
|
|
article.preferences['delivery_status'] = 'success'
|
|
article.preferences['delivery_status_date'] = Time.zone.now
|
|
article.preferences['delivery_status_date'] = Time.zone.now
|
|
|
|
|
|
- article.message_id = tweet_id
|
|
|
|
- article.preferences['links'] = [
|
|
|
|
- {
|
|
|
|
- url: "https://twitter.com/statuses/#{tweet_id}",
|
|
|
|
- target: '_blank',
|
|
|
|
- name: 'on Twitter',
|
|
|
|
- },
|
|
|
|
- ]
|
|
|
|
-
|
|
|
|
article.save!
|
|
article.save!
|
|
|
|
|
|
Rails.logger.info "Send twitter (#{tweet_type}) to: '#{article.to}' (from #{article.from})"
|
|
Rails.logger.info "Send twitter (#{tweet_type}) to: '#{article.to}' (from #{article.from})"
|