示例#1
0
    def follow(self,
               target_feed_slug,
               target_user_id,
               activity_copy_limit=None,
               **extra_data):
        """
        Follows the given feed

        :param activity_copy_limit: how many activities should be copied from target feed
        :param target_feed_slug: the slug of the target feed
        :param target_user_id: the user id
        """
        target_feed_slug = validate_feed_slug(target_feed_slug)
        target_user_id = validate_user_id(target_user_id)
        target_feed_id = "%s:%s" % (target_feed_slug, target_user_id)
        url = self.feed_url + "follows/"
        data = {
            "target":
            target_feed_id,
            "target_token":
            self.client.feed(target_feed_slug, target_user_id).token,
        }
        if activity_copy_limit is not None:
            data["activity_copy_limit"] = activity_copy_limit
        token = self.create_scope_token("follower", "write")
        data.update(extra_data)
        response = self.client.post(url, data=data, signature=token)
        return response
示例#2
0
    def follow(self,
               target_feed_slug,
               target_user_id,
               activity_copy_limit=None,
               **extra_data):
        '''
        Follows the given feed

        :param target_feed_slug: the slug of the target feed
        :param target_user_id: the user id
        '''
        target_feed_slug = validate_feed_slug(target_feed_slug)
        target_user_id = validate_user_id(target_user_id)
        target_feed_id = '%s:%s' % (target_feed_slug, target_user_id)
        url = self.feed_url + 'follows/'
        data = {
            'target':
            target_feed_id,
            'target_token':
            self.client.feed(target_feed_slug, target_user_id).token
        }
        if activity_copy_limit != None:
            data['activity_copy_limit'] = activity_copy_limit
        token = self.create_scope_token('follower', 'write')
        data.update(extra_data)
        response = self.client.post(url, data=data, signature=token)
        return response
示例#3
0
 def unfollow(self, target_feed_slug, target_user_id):
     '''
     Unfollow the given feed
     '''
     target_feed_slug = validate_feed_slug(target_feed_slug)
     target_user_id = validate_user_id(target_user_id)
     target_feed_id = '%s:%s' % (target_feed_slug, target_user_id)
     url = self.feed_url + 'follows/%s/' % target_feed_id
     response = self.client.delete(url, signature=self.signature)
     return response
示例#4
0
    def feed(self, feed_slug, user_id):
        """
        Returns a Feed object

        :param feed_slug: the slug of the feed
        :param user_id: the user id
        """
        feed_slug = validate_feed_slug(feed_slug)
        user_id = validate_user_id(user_id)
        token = self.create_jwt_token("feed", "*", feed_id="*")
        return Feed(self, feed_slug, user_id, token)
示例#5
0
    def feed(self, feed_slug, user_id):
        """
        Returns a Feed object

        :param feed_slug: the slug of the feed
        :param user_id: the user id
        """
        feed_slug = validate_feed_slug(feed_slug)
        user_id = validate_user_id(user_id)
        token = self.create_jwt_token("feed", "*", feed_id="*")
        return Feed(self, feed_slug, user_id, token)
示例#6
0
 def unfollow(self, target_feed_slug, target_user_id, keep_history=False):
     """
     Unfollow the given feed
     """
     target_feed_slug = validate_feed_slug(target_feed_slug)
     target_user_id = validate_user_id(target_user_id)
     target_feed_id = "%s:%s" % (target_feed_slug, target_user_id)
     token = self.create_scope_token("follower", "delete")
     url = self.feed_url + "follows/%s/" % target_feed_id
     params = {}
     if keep_history:
         params["keep_history"] = True
     response = self.client.delete(url, signature=token, params=params)
     return response
示例#7
0
 def unfollow(self, target_feed_slug, target_user_id, keep_history=False):
     """
     Unfollow the given feed
     """
     target_feed_slug = validate_feed_slug(target_feed_slug)
     target_user_id = validate_user_id(target_user_id)
     target_feed_id = "%s:%s" % (target_feed_slug, target_user_id)
     token = self.create_scope_token("follower", "delete")
     url = self.feed_url + "follows/%s/" % target_feed_id
     params = {}
     if keep_history:
         params["keep_history"] = True
     response = self.client.delete(url, signature=token, params=params)
     return response
示例#8
0
 def unfollow(self, target_feed_slug, target_user_id, keep_history=False):
     '''
     Unfollow the given feed
     '''
     target_feed_slug = validate_feed_slug(target_feed_slug)
     target_user_id = validate_user_id(target_user_id)
     target_feed_id = '%s:%s' % (target_feed_slug, target_user_id)
     token = self.create_scope_token('follower', 'delete')
     url = self.feed_url + 'follows/%s/' % target_feed_id
     params = {}
     if keep_history:
         params['keep_history'] = True
     response = self.client.delete(url, signature=token, params=params)
     return response
示例#9
0
 def unfollow(self, target_feed_slug, target_user_id, keep_history=False):
     '''
     Unfollow the given feed
     '''
     target_feed_slug = validate_feed_slug(target_feed_slug)
     target_user_id = validate_user_id(target_user_id)
     target_feed_id = '%s:%s' % (target_feed_slug, target_user_id)
     token = self.create_scope_token('follower', 'delete')
     url = self.feed_url + 'follows/%s/' % target_feed_id
     params = {}
     if keep_history:
         params['keep_history'] = True
     response = self.client.delete(url, signature=token, params=params)
     return response
示例#10
0
    def feed(self, feed_slug, user_id):
        '''
        Returns a Feed object

        :param feed_slug: the slug of the feed
        :param user_id: the user id
        '''
        from stream.feed import Feed
        feed_slug = validate_feed_slug(feed_slug)
        user_id = validate_user_id(user_id)

        # generate the token
        feed_id = '%s%s' % (feed_slug, user_id)
        token = sign(self.api_secret, feed_id)

        return Feed(self, feed_slug, user_id, token)
示例#11
0
    def feed(self, feed_slug, user_id):
        '''
        Returns a Feed object

        :param feed_slug: the slug of the feed
        :param user_id: the user id
        '''
        from stream.feed import Feed
        feed_slug = validate_feed_slug(feed_slug)
        user_id = validate_user_id(user_id)

        # generate the token
        feed_id = '%s%s' % (feed_slug, user_id)
        token = sign(self.api_secret, feed_id)

        return Feed(self, feed_slug, user_id, token)
示例#12
0
    def follow(self, target_feed_slug, target_user_id):
        '''
        Follows the given feed

        :param target_feed_slug: the slug of the target feed
        :param target_user_id: the user id
        '''
        target_feed_slug = validate_feed_slug(target_feed_slug)
        target_user_id = validate_user_id(target_user_id)
        target_feed_id = '%s:%s' % (target_feed_slug, target_user_id)
        url = self.feed_url + 'follows/'
        data = {
            'target': target_feed_id,
            'target_token': self.client.feed(target_feed_slug, target_user_id).token
        }
        response = self.client.post(
            url, data=data, signature=self.signature)
        return response
示例#13
0
    def follow(self, target_feed_slug, target_user_id, **extra_data):
        '''
        Follows the given feed

        :param target_feed_slug: the slug of the target feed
        :param target_user_id: the user id
        '''
        target_feed_slug = validate_feed_slug(target_feed_slug)
        target_user_id = validate_user_id(target_user_id)
        target_feed_id = '%s:%s' % (target_feed_slug, target_user_id)
        url = self.feed_url + 'follows/'
        data = {
            'target': target_feed_id,
            'target_token': self.client.feed(target_feed_slug, target_user_id).token
        }
        data.update(extra_data)
        response = self.client.post(
            url, data=data, signature=self.signature)
        return response
示例#14
0
    def follow(self, target_feed_slug, target_user_id, **extra_data):
        '''
        Follows the given feed

        :param target_feed_slug: the slug of the target feed
        :param target_user_id: the user id
        '''
        target_feed_slug = validate_feed_slug(target_feed_slug)
        target_user_id = validate_user_id(target_user_id)
        target_feed_id = '%s:%s' % (target_feed_slug, target_user_id)
        url = self.feed_url + 'follows/'
        data = {
            'target': target_feed_id,
            'target_token': self.client.feed(target_feed_slug, target_user_id).token
        }
        token = self.create_scope_token('follower', 'write')
        data.update(extra_data)
        response = self.client.post(
            url, data=data, signature=token)
        return response
示例#15
0
    def follow(
        self, target_feed_slug, target_user_id, activity_copy_limit=None, **extra_data
    ):
        """
        Follows the given feed

        :param activity_copy_limit: how many activities should be copied from target feed
        :param target_feed_slug: the slug of the target feed
        :param target_user_id: the user id
        """
        target_feed_slug = validate_feed_slug(target_feed_slug)
        target_user_id = validate_user_id(target_user_id)
        target_feed_id = "%s:%s" % (target_feed_slug, target_user_id)
        url = self.feed_url + "follows/"
        data = {
            "target": target_feed_id,
            "target_token": self.client.feed(target_feed_slug, target_user_id).token,
        }
        if activity_copy_limit is not None:
            data["activity_copy_limit"] = activity_copy_limit
        token = self.create_scope_token("follower", "write")
        data.update(extra_data)
        response = self.client.post(url, data=data, signature=token)
        return response