diff --git a/Changelog.md b/Changelog.md index e2b95982d..6194bea43 100644 --- a/Changelog.md +++ b/Changelog.md @@ -45,6 +45,7 @@ A new feature [has been added](https://github.com/diaspora/diaspora/pull/4602) t * 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) diff --git a/app/models/services/twitter.rb b/app/models/services/twitter.rb index e33979c2b..efa13799e 100644 --- a/app/models/services/twitter.rb +++ b/app/models/services/twitter.rb @@ -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