1- from stream .utils import validate_feed_id , validate_user_id , validate_feed_slug
1+ from stream .utils import validate_feed_id , validate_feed_slug , validate_user_id
22
33
4- class Feed ( object ) :
4+ class Feed :
55 def __init__ (self , client , feed_slug , user_id , token ):
66 """
77 Initializes the Feed class
@@ -61,8 +61,7 @@ def add_activity(self, activity_data):
6161 activity_data ["to" ] = self .add_to_signature (activity_data ["to" ])
6262
6363 token = self .create_scope_token ("feed" , "write" )
64- result = self .client .post (self .feed_url , data = activity_data , signature = token )
65- return result
64+ return self .client .post (self .feed_url , data = activity_data , signature = token )
6665
6766 def add_activities (self , activity_list ):
6867 """
@@ -87,8 +86,8 @@ def add_activities(self, activity_list):
8786 token = self .create_scope_token ("feed" , "write" )
8887 data = dict (activities = activities )
8988 if activities :
90- result = self .client .post (self .feed_url , data = data , signature = token )
91- return result
89+ return self .client .post (self .feed_url , data = data , signature = token )
90+ return None
9291
9392 def remove_activity (self , activity_id = None , foreign_id = None ):
9493 """
@@ -106,8 +105,7 @@ def remove_activity(self, activity_id=None, foreign_id=None):
106105 token = self .create_scope_token ("feed" , "delete" )
107106 if foreign_id is not None :
108107 params ["foreign_id" ] = "1"
109- result = self .client .delete (url , signature = token , params = params )
110- return result
108+ return self .client .delete (url , signature = token , params = params )
111109
112110 def get (self , enrich = False , reactions = None , ** params ):
113111 """
@@ -143,8 +141,7 @@ def get(self, enrich=False, reactions=None, **params):
143141 if reactions .get ("counts" ):
144142 params ["withReactionCounts" ] = True
145143
146- response = self .client .get (feed_url , params = params , signature = token )
147- return response
144+ return self .client .get (feed_url , params = params , signature = token )
148145
149146 def follow (
150147 self , target_feed_slug , target_user_id , activity_copy_limit = None , ** extra_data
@@ -168,8 +165,7 @@ def follow(
168165 data ["activity_copy_limit" ] = activity_copy_limit
169166 token = self .create_scope_token ("follower" , "write" )
170167 data .update (extra_data )
171- response = self .client .post (url , data = data , signature = token )
172- return response
168+ return self .client .post (url , data = data , signature = token )
173169
174170 def unfollow (self , target_feed_slug , target_user_id , keep_history = False ):
175171 """
@@ -183,31 +179,27 @@ def unfollow(self, target_feed_slug, target_user_id, keep_history=False):
183179 params = {}
184180 if keep_history :
185181 params ["keep_history" ] = True
186- response = self .client .delete (url , signature = token , params = params )
187- return response
182+ return self .client .delete (url , signature = token , params = params )
188183
189184 def followers (self , offset = 0 , limit = 25 , feeds = None ):
190185 """
191186 Lists the followers for the given feed
192187 """
193- feeds = feeds is not None and "," .join (feeds ) or ""
188+ feeds = "," .join (feeds ) if feeds is not None else ""
194189 params = {"limit" : limit , "offset" : offset , "filter" : feeds }
195190 url = self .feed_url + "followers/"
196191 token = self .create_scope_token ("follower" , "read" )
197- response = self .client .get (url , params = params , signature = token )
198- return response
192+ return self .client .get (url , params = params , signature = token )
199193
200194 def following (self , offset = 0 , limit = 25 , feeds = None ):
201195 """
202196 List the feeds which this feed is following
203197 """
204- if feeds is not None :
205- feeds = feeds is not None and "," .join (feeds ) or ""
198+ feeds = "," .join (feeds ) if feeds is not None else ""
206199 params = {"offset" : offset , "limit" : limit , "filter" : feeds }
207200 url = self .feed_url + "follows/"
208201 token = self .create_scope_token ("follower" , "read" )
209- response = self .client .get (url , params = params , signature = token )
210- return response
202+ return self .client .get (url , params = params , signature = token )
211203
212204 def add_to_signature (self , recipients ):
213205 """
0 commit comments