Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug fix for twitter fetch_mentions: user_mentions are in entities field
  • Loading branch information
snarfed committed Nov 22, 2015
1 parent 6e574e0 commit e0da542
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion granary/test/test_twitter.py
Expand Up @@ -682,7 +682,7 @@ def test_get_activities_fetch_mentions(self):
self.expect_urlopen(
'https://api.twitter.com/1.1/statuses/lookup.json?id=11,12,13&include_entities=true',
[{'id_str': '11', 'user': {'screen_name': 'schnarfed'}},
{'id_str': '12', 'user_mentions': [{'screen_name': 'schnarfed'}]},
{'id_str': '12', 'entities': {'user_mentions': [{'screen_name': 'schnarfed'}]}},
{'id_str': '13', 'text': 'barrey'},
])
self.mox.ReplayAll()
Expand Down
3 changes: 2 additions & 1 deletion granary/twitter.py
Expand Up @@ -421,7 +421,8 @@ def fetch_mentions(self, username, min_id=None):
mentions.append(c)
else:
reply_to_user = reply_to.get('user', {}).get('screen_name')
mentioned = [u.get('screen_name') for u in reply_to.get('user_mentions', [])]
mentioned = [u.get('screen_name') for u in
reply_to.get('entities', {}).get('user_mentions', [])]
if username != reply_to_user and username not in mentioned:
mentions.append(c)

Expand Down

0 comments on commit e0da542

Please sign in to comment.