Child Reactions

Last Edit: Feb 02 2020

A reaction can also be added to another reaction; in this case, a child reaction is created. Child reactions are created in the same way as regular reactions but have a few crucial differences:

  • Child reactions are not part of the parent activity counts

  • Child reactions are only returned when the parent is returned

  • In order to paginate over reactions, you need to filter using the parent reaction ID

  • Recent children reactions and their counts are added to the parent reaction body

Reaction nesting is limited. The deepest level where you can insert your child reaction is 3.

Let's take an example: Bob creates an activity

  1. Alice comments on this activity

  2. Bob comments on Alice's comment

  3. Carl comments on Bob's comment.

Carl's comment is at the maximum third nesting level, so Alice can't like or comment on Carl's comment because it would be the fourth level of nesting.


// adds a like to the previously created comment
client.reactions.addChild('like', comment);
                    

# adds a like to the previously created comment
client.reactions.add_child("like", comment, user_id="mike")
                    

# adds a like to the previously created comment
client.reactions.add_child("like", comment_id, user_id="mike")
                    

// adds a like to the previously created comment
$client->reactions()->addChild("like", $comment_id, "mike");
                    

Reaction reaction = Reaction.builder().kind("like").build();
// adds a like to the previously created comment
reaction = client.reactions().addChild("john-doe", comment.getId(), reaction).get();
                    

// adds a like to the previously created comment
r := stream.AddReactionRequestObject{
	Kind:       "like",
	ActivityID: activity.ID,
	UserID:     "bob",
}
result, err := client.Reactions().AddChild(comment.ID, r)
                    

// add a like reaction to the previously created comment
client.add(reactionToParentReaction: commentReaction, kindOf: "like") { result in /* ... */ }
                    

// adds a like to the previously created comment
await client.Reactions.AddChild(comment, "like", activity.Id, "bob")