Permalink
Browse files

šŸž Fix max tweet length and truncation

  • Loading branch information...
adamdawkins committed Jan 21, 2019
1 parent 3b63967 commit 6c4d41ffb7093e45c179b0df2b343fab2a3ec818
Showing with 4 additions and 7 deletions.
  1. +4 āˆ’7 app/services/twitter_service.rb
@@ -12,14 +12,11 @@ def self.post(post)
tweet = post.content
tweet.gsub!('*', 'ļ¼Š')
if (tweet.length > MAX_TWEET_LENGTH)
pp "too long"
pp post.id
url = "#{ENV['SHORT_URL']}/#{post.id}"
pp url
cut_off = MAX_TWEET_LENGTH - url.length - 4 # the 4 is 3 elipses dots + a space or return
tweet = "#{tweet[0..cut_off]}...\r#{url}"
url = "https://#{ENV['SHORT_URL']}/#{post.id}"
cut_off = MAX_TWEET_LENGTH - 23 - 4 - 10 # extra 10, don't know why it's needed yet
tweet = "#{tweet[0..(cut_off - 1)]}... #{url}"
end
response = TwitterClient.update(tweet)
response = TwitterClient.update(tweet, tweet_mode: 'extended')

twitter_silo = Silo.find_by(name: "Twitter")

0 comments on commit 6c4d41f

Please sign in to comment.