Search code examples
flutterkotlingetstream-io

Getstream.io get like count and users who liked


My add like function looks like this (kotlin)

private fun addLike(user: String, token: String, activityID: String) {
    val client = CloudClient.builder(API_KEY, token, user).build()
    val like = Reaction.Builder().kind("like").activityID(activityID).build()
    client.reactions().add(user, like).join()
}

and the read is:

private fun getActivitiesForTeam(user: String, token: String, team: String): List<EnrichedActivity> {
    val client = CloudClient.builder(API_KEY, token, user).build()
    return client.flatFeed(team, "messages")
            .getEnrichedActivities(Limit(25), EnrichmentFlags().withOwnReactions().withRecentReactions().withReactionCounts()).join()
}

When I got the latest_reactions_extra field this will be:

latest_reactions_extra {} // I think this will be the empty

or

latest_reactions_extra {like: {next: }} //this is the not empty? But why is it nullstring?

So how can I get the like count and the users who liked?

Also how can I delete that like? I got nothing like a 'reactionID' but the docs says it will be something called reactionID

Thanks

EDIT

private fun addLike(user: String, token: String, activityID: String) {
    val client = CloudClient.builder(API_KEY, token, user).build()
    val like = Reaction.Builder().kind("like").activityID(activityID).userID(user).build()
    client.reactions().add(user, like).get()
}

result.success(ObjectMapper().writeValueAsString(reaction))

when I modified the addLike function to this, I got this:

latest_reactions_extra {like: {next: https://stream-io-api.com/api/v1.0/reaction/activity_id/34oijgiojiojgiojijoijoij-tgrgrtgrtgt/like/?id_lt=ergerg-01e1-4b73-b88d-regger&limit=5&withOwnChildren=false}}

What is this?

SOLUTION

OK it looks like fasterxml ObjectMapper just erased/killed my reactions field, so I had to create the json string in an other way...:/


Solution

  • SOLUTION

    OK it looks like fasterxml ObjectMapper just erased/killed my reactions field, so I had to create the json string in an other way...:/