Skip to content

Commit cd25d75

Browse files
committed
Merge branch 'master' of github.com:tschellenbach/stream-python
2 parents b651bc3 + 55e4eaa commit cd25d75

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ result = user_feed_1.get(limit=5, offset=5)
3333
result = user_feed_1.get(limit=5, id_lt="e561de8f-00f1-11e4-b400-0cc47a024be0")
3434

3535
# Create a new activity
36-
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1}
36+
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'foreign_id': 'tweet:1'}
3737
activity_response = user_feed_1.add_activity(activity_data)
3838

3939
# Remove an activity by its id
4040
user_feed_1.remove("e561de8f-00f1-11e4-b400-0cc47a024be0")
41+
# or by foreign id
42+
user_feed_1.remove(foreign_id='tweet:1')
4143

4244
# Follow another feed
4345
user_feed_1.follow('flat:42')

‎stream/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__copyright__ = 'Copyright 2012, Thierry Schellenbach'
55
__credits__ = ['Thierry Schellenbach, mellowmorning.com, @tschellenbach']
66
__license__ = 'BSD'
7-
__version__ = '0.3.0'
7+
__version__ = '0.3.1'
88
__maintainer__ = 'Thierry Schellenbach'
99
__email__ = 'thierryschellenbach@gmail.com'
1010
__status__ = 'Production'

‎stream/feed.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,22 @@ def add_activities(self, activity_list):
5454
self.feed_url, data=data, authorization=self.authorization)
5555
return result
5656

57-
def remove_activity(self, activity_id):
57+
def remove_activity(self, activity_id=None, foreign_id=None):
5858
'''
5959
Removes an activity from the feed
6060
6161
:param activity_id: the activity id to remove from this feed
6262
(note this will also remove the activity from feeds which follow this feed)
63+
:param foreign_id: the foreign id you provided when adding the activity
6364
'''
64-
url = self.feed_url + '%s/' % activity_id
65-
result = self.client.delete(url, authorization=self.authorization)
65+
identifier = activity_id or foreign_id
66+
if not identifier:
67+
raise ValueError('please either provide activity_id or foreign_id')
68+
url = self.feed_url + '%s/' % identifier
69+
params = dict()
70+
if foreign_id is not None:
71+
params['foreign_id'] = '1'
72+
result = self.client.delete(url, authorization=self.authorization, params=params)
6673
return result
6774

6875
def follow(self, target_feed):

‎stream/tests.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ def test_remove_activity(self):
6868
activities = self.user1.get(limit=1)['results']
6969
self.assertNotEqual(activities[0]['id'], activity_id)
7070

71+
def test_remove_activity_by_foreign_id(self):
72+
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'foreign_id': 'tweet:10'}
73+
activity_id = self.user1.add_activity(activity_data)['id']
74+
self.user1.remove_activity(foreign_id='tweet:10')
75+
activities = self.user1.get(limit=1)['results']
76+
self.assertNotEqual(activities[0]['id'], activity_id)
77+
7178
def test_add_activities(self):
7279
activity_data = [
7380
{'actor': 1, 'verb': 'tweet', 'object': 1},

0 commit comments

Comments
 (0)