Skip to content

Commit 126d6aa

Browse files
committed
Added activity_copy_limit to follow_many
1 parent fd925f7 commit 126d6aa

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎stream/client.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,20 @@ def add_to_many(self, activity, feeds):
235235
data = {'activity': activity, 'feeds': feeds}
236236
self._make_signed_request('post', 'feed/add_to_many/', data=data)
237237

238-
def follow_many(self, follows):
238+
def follow_many(self, follows, activity_copy_limit=None):
239239
'''
240240
Creates many follows
241241
:param follows: the list of follow relations
242242
243243
eg. [{'source': source, 'target': target}]
244244
245245
'''
246-
self._make_signed_request('post', 'follow_many/', data=follows)
246+
params = None
247+
248+
if activity_copy_limit != None:
249+
params = dict(activity_copy_limit=activity_copy_limit)
250+
251+
self._make_signed_request('post', 'follow_many/', params=params, data=follows)
247252

248253
def update_activities(self, activities):
249254
'''

‎stream/tests.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,22 @@ def test_follow_many(self):
701701
self.assertEqual(follows[0]['feed_id'], source)
702702
self.assertIn(follows[0]['target_id'], targets)
703703

704+
def test_follow_many_acl(self):
705+
sources = [getfeed('user', str(i)) for i in range(10)]
706+
targets = [getfeed('flat', str(i)) for i in range(10)]
707+
sources_id = [source.id for source in sources]
708+
targets_id = [target.id for target in targets]
709+
feeds = [{'source': s, 'target': t} for s,t in zip(sources_id, targets_id)]
710+
711+
for target in targets:
712+
target.add_activity({ 'actor': 'barry', 'object': '09', 'verb': 'tweet' })
713+
714+
self.c.follow_many(feeds, activity_copy_limit=0)
715+
716+
for source in sources:
717+
activities = source.get(limit=5)['results']
718+
self.assertEqual(len(activities), 0)
719+
704720
def test_add_to_many(self):
705721
activity = {'actor': 1, 'verb': 'tweet', 'object': 1, 'custom': 'data'}
706722
feeds = [getfeed('flat', str(i)).id for i in range(10, 20)]

0 commit comments

Comments
 (0)