Skip to content

Commit

Permalink
mentions search: explicitly drop reshares and likes. fixes #494
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Sep 29, 2015
1 parent 1682df7 commit d71acdf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ def poll(self, source):
mentions = source.get_activities_response(
search_query=search_query, group_id=gr_source.SEARCH, **kwargs
).get('items', [])
# strip shares and likes. (some silos get and return them without
# explicitly fetching them.)
for m in mentions:
m['object']['tags'] = [tag for tag in m['object'].get('tags', [])
if tag.get('verb') not in ('like', 'share')]

mentions = {m['id']: m for m in mentions}
activities.update(mentions) # so that we handle replies to mentions
responses.update(mentions)
Expand Down
11 changes: 11 additions & 0 deletions test/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,17 @@ def test_search_for_mentions_backfeed_posts_and_comments(self):
'id': 'tag:source.com,2013:9_comment',
'content': 'foo bar',
}]},
'tags': [{
'id': 'tag:source.com,2013:9_like',
'objectType': 'activity',
'verb': 'like',
'object': {'url': 'http://example.com/abc'},
}, {
'id': 'tag:source.com,2013:9_reshare',
'objectType': 'activity',
'verb': 'share',
'object': {'url': 'http://example.com/def'},
}],
},
}
source.set_search_results([copy.deepcopy(mention)])
Expand Down

0 comments on commit d71acdf

Please sign in to comment.