I would like to check if a user has already liked an activity/comment before, so I would like to get the likes of a user on an activity, or the likes of a user on a comment. However, this populates all reactions on an activity/comment instead of filtering only the user's reactions.
client.feed('user', 'Amy').get({ withReactionCounts: true, withOwnReactions: true })
I have tried the workaround commented on the Github project and tried playing around with both withOwnReactions
and ownReactions
based on this question but to no avail.
I currently have stream-js
v7.2.11 installed.
Thanks!
The parameters should be reactions.own
and reactions.counts
.
client.feed('user', 'Amy').get({reactions: {own: true, counts: true})
The other thing you need to do if you are making a server side call is to make sure you are calling it with a user token for the user you wish to see own reactions for, otherwise it will give you everything, as the client won't know who "own" refers to.
//Create the server side client
const serverClient = stream.connect(
'abcde12345',
'somereallylongandverysecretapikeythatyoushouldnotshareonstackoverflow',
'123456');
//Create the user specific token
const userToken = serverClient.createUserToken('Amy');
//Create the user specific client
const userClient = stream.connect('abcde12345', userToken, '123456');
Now you should be able to get data from your feed with own_reactions
populated only with data for the user you specified.
userClient.feed('user', 'Amy').get({reactions: {own: true, counts: true})
An additional gotcha is that if you create a new feed group other than the default ones Stream creates, than you will also need to email Stream's support team to ask them to change the permission to "Global Read" otherwise you'll get a 403 error. There doesn't seem to be any way to do it via their console. The user feed group is set to Global Read by default, but new feed groups are set to private. Their support was very helpful and fixed it up for me in less than an hour.