Enriched reactions
See original GitHub issueHi there,
I’d like to know if getStream feeds support the enrichment of reactions, because I’d like to store references to objects like author inside the reaction and have it enriched automatically as I can do with activities.
I tried to store objects (created from collections.add) inside a reaction’s data but I wasn’t able because an error was thrown. So I’m not sure if this is an error, or if this is something that you don’t support.
To store objects inside reactions I was doing this
const author = await client.collections.add('authors', null, {
name: 'Author',
})
await client.reactions.add("comment", activity.id, { text: "nice post!", author }, { userId: user.id })
But then the following is error was being thrown
Error: Converting circular structure to JSON –> starting at object with constructor ‘StreamClient’ | property ‘personalization’ -> object with constructor ‘Personalization’ — property ‘client’ closes the circle
Instead of adding the full author object to the reaction, I was able to add author.id and also author.data, but that way the object will not be enriched / updated once the author is updated
But first I’d need to know if getStream supports or not enriched reactions
I’m using latest version (8.0.0)
Thanks
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
@ferhatelmas it worked
I was trying to send the whole object because when I add this way on activities it works.
Thank you!
There is a problem in your example because you’re calling
addChild
which means you’re trying to add a comment to existing comment butparent
of your response is empty so it’s a comment on activity. That’s why that response isn’t coming that request.Problem is here:
if
activityId
exists you need to callclient.reactions.add
, otherwise callclient.reaction.addChild
.Overall, you’re adding custom data, not a reference and you don’t want to enrich it. I believe, your issue is irrelevant to this ticket.