From 6c416e80db640dce1ee114b2f2a3e9a8fdd7b225 Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Fri, 3 May 2013 21:19:59 +0200 Subject: [PATCH] Fix in `diaspy.streams.FollowedTags` method `add()`: doesn't crash when trying to follow a tag that is already being followed --- diaspy/streams.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/diaspy/streams.py b/diaspy/streams.py index 8eea26d..a91a376 100644 --- a/diaspy/streams.py +++ b/diaspy/streams.py @@ -276,7 +276,7 @@ class Mentions(Generic): class FollowedTags(Generic): """This stream contains all posts - containing a tag the user is following. + containing tags the user is following. """ def _setlocation(self): self._location = 'followed_tags.json' @@ -294,9 +294,12 @@ class FollowedTags(Generic): def add(self, tag_name): """Follow new tag. + Error code 403 is accepted because pods respod with it when request + is sent to follow a tag that a user already follows. :param tag_name: tag name :type tag_name: str + :returns: int (response code) """ data = {'name':tag_name, 'authenticity_token':self._connection.get_token(), @@ -307,5 +310,6 @@ class FollowedTags(Generic): request = self._connection.post('tag_followings', data=json.dumps(data), headers=headers) - if request.status_code != 201: + if request.status_code not in [201, 403]: raise Exception('wrong error code: {0}'.format(request.status_code)) + return request.status_code -- 2.25.1