Reputation:
Does Stream have a method to obtain whether a user follows a user or not? Would be handy when determining if it's appropriate to show a follow or unfollow button. I'm building a Django REST API and so I'm trying to pass a boolean that dictates "is following", is there a better suggestion?
I've tried the below:
userfeed = stream_client.feed('userposts', request.user.pk)
for follows in userfeed.following(offset=5, limit=25):
# check if user is following a feed
I'd think it would be good to have a method to do this rather than having to loop through all of a user's following objects myself.
I know in some of the examples in Django a model is created to store the relationship but I feel with how extensive stream's API is now it would be faster to do the translation there versus the relational database. Worst case I'll likely be creating another model but to me ideally there'd be a way around it.
Upvotes: 2
Views: 367
Reputation: 12031
The API endpoint to read followed feeds has a filter parameter that allows you to only limit the results to feeds matching one of the values.
// Check if user1 follows specific feeds
user1.following({offset: 0, limit: 2, filter: ['user:42', 'user:43']})
Upvotes: 2