Skip to content

Commit

Permalink
twitter: bug fix for stripping quoted tweet URL from end of quote twe…
Browse files Browse the repository at this point in the history
…et text

for snarfed/bridgy#728

still a remaining unrelated bug to fix with tweets with both media and other entities, e.g. @-mentions.
  • Loading branch information
snarfed committed Feb 16, 2017
1 parent 435c6c4 commit 67e9089
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ Changelog
* Twitter:
* Linkify @-mentions and hashtags in `preview_create()`.
* Support creating quote tweets from attachments with Twitter URLs.
* When converting quote tweets to AS, strip quoted tweet URL from end of text.
* Instagram:
* Improve HTML scraping error handling.
* Facebook:
Expand Down
9 changes: 4 additions & 5 deletions granary/test/test_twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,13 +1082,12 @@ def test_quote_tweet_to_activity_without_quoted_tweet_url_entity(self):
quote_tweet = copy.deepcopy(QUOTE_TWEET)
quote_tweet['entities']['urls'][0]['expanded_url'] = 'http://foo/bar'

suffix = u' twitter.com/schnar…'
content = self.twitter.tweet_to_activity(quote_tweet)['object']['content']
self.assertTrue(content.endswith(suffix), content)
self.assert_equals(u'I agree with this twitter.com/schnar…',
self.twitter.tweet_to_activity(quote_tweet)['object']['content'])

del quote_tweet['entities']
activity = self.twitter.tweet_to_activity(quote_tweet)['object']['content']
self.assertTrue(content.endswith(suffix), content)
self.assert_equals('I agree with this https://t.co/ww6HD8KroG',
self.twitter.tweet_to_activity(quote_tweet)['object']['content'])

def test_tweet_to_object_full(self):
self.assert_equals(OBJECT, self.twitter.tweet_to_object(TWEET))
Expand Down
1 change: 0 additions & 1 deletion granary/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ def tweet_to_object(self, tweet):

# text content. linkify entities. convert start/end indices to start/length,
# and replace t.co URLs with real "display" URLs.
text = base_tweet.get('text') or ''
text_start, text_end = (0, len(text))

full_text = base_tweet.get('full_text')
Expand Down

0 comments on commit 67e9089

Please sign in to comment.