Fix posting to Twitter by correctly catching over limit exception (#4627). Also when doing a retry, make smaller cuts to max characters
This commit is contained in:
parent
5c81da3147
commit
e665ebdab1
2 changed files with 3 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue