Merge pull request #4628 from jaywink/4627-twitter-truncation-problem

Fix posting to Twitter by correctly catching over limit exception
This commit is contained in:
Jonne Haß 2013-12-22 14:14:30 -08:00
commit 5d83402dc3
2 changed files with 3 additions and 2 deletions

View file

@ -59,6 +59,7 @@ For more details see https://wiki.diasporafoundation.org/Updating
* Add lightbox to unauthenticated header, fix [#4432](https://github.com/diaspora/diaspora/issues/4432)
* Fix "more picture" indication (+n) on mobile by adding a link on the indication [#4592](https://github.com/diaspora/diaspora/pull/4592)
* Display errors when photo upload fails [#4509](https://github.com/diaspora/diaspora/issues/4509)
* Fix posting to Twitter by correctly catching exception [#4627](https://github.com/diaspora/diaspora/issues/4627)
## Features
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)

View file

@ -42,7 +42,7 @@ class Services::Twitter < Service
message = build_twitter_post post, retry_count
tweet = client.update message
rescue Twitter::Error::Forbidden => e
if e.message != 'Status is over 140 characters' || retry_count == 20
if ! e.message.include? 'is over 140' || retry_count == 20
raise e
else
attempt_post post, retry_count+1
@ -50,7 +50,7 @@ class Services::Twitter < Service
end
def build_twitter_post post, retry_count=0
max_characters = MAX_CHARACTERS - retry_count * 5
max_characters = MAX_CHARACTERS - retry_count
post_text = strip_markdown post.text(plain_text: true)
truncate_and_add_post_link post, post_text, max_characters