Activity Feeds V3 is in closed alpha — do not use it in production (just yet).

Reactions

Overview

You can react to both activities and comments. It’s possible to configure any reaction types that best fit your app.

When adding reactions and the enforce_unique flag is set to true, the existing reaction of a user will be overridden with the new reaction. Use this flag if you want to ensure users have a single reaction per each comment/activity. The default value is false, in which case users can have multiple reactions.

# Add a reaction to an activity
reaction_request = GetStream::Generated::Models::AddReactionRequest.new(
  type: 'like',
  user_id: 'user123',
  custom: {
    emoji: '❤️'
  }
)

response = client.feeds.add_reaction(activity_id, reaction_request)

# Adding a reaction without triggering push notifications
reaction_request_skip_push = GetStream::Generated::Models::AddReactionRequest.new(
  type: 'like',
  user_id: 'user123',
  custom: {
    emoji: '❤️'
  },
  skip_push: true
)

response = client.feeds.add_reaction(activity_id, reaction_request_skip_push)

# Add a reaction to a comment
comment_reaction_request = GetStream::Generated::Models::AddCommentReactionRequest.new(
  type: 'like',
  user_id: 'user123',
  custom: {
    emoji: '👍'
  }
)

response = client.feeds.add_comment_reaction(comment_id, comment_reaction_request)

# Delete activity reaction
response = client.feeds.delete_activity_reaction(activity_id, 'like', 'user123')

By default creating a reaction doesn’t create an activity.

When you read a feed the reactions are included. Here’s an example:

# Query reactions to a specific activity
query_request = GetStream::Generated::Models::QueryActivityReactionsRequest.new(
  limit: 10,
  filter: {
    reaction_type: 'like'
  }
)

response = client.feeds.query_activity_reactions(activity_id, query_request)

# Access reaction data
puts response.reactions
puts response.reaction_groups

Querying Reactions

You can query reactions to both activities and comments. Here are some examples:

// Query reactions to a specific activity
val activityReactionList = client.activityReactionList(
    ActivityReactionsQuery(
        activityId = "activity-123",
        filter = ActivityReactionsFilterField.reactionType.equal("like"),
    )
)
activityReactionList.get()
activityReactionList.state.reactions.collect { reactions ->
    // Handle activity reactions
}

// Query reactions to a specific comment
val commentReactionList = client.commentReactionList(
    CommentReactionsQuery(
        commentId = "comment-456",
        filter = CommentReactionsFilterField.reactionType.equal("like"),
    )
)
commentReactionList.get()
commentReactionList.state.reactions.collect { reactions ->
    // Handle comment reactions
}

Reaction Queryable Built-In Fields

nametypedescriptionsupported operationsexample
reaction_typestring or list of stringsThe type of reaction$in, $eq{ reaction_type: { $in: [ 'like', 'heart', 'thumbs_up' ] } }
user_idstring or list of stringsThe ID of the user who created the reaction$in, $eq{ user_id: { $eq: 'user_123' } }
created_atstring, must be formatted as an RFC3339 timestampThe time the reaction was created$eq, $gt, $gte, $lt, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }
© Getstream.io, Inc. All Rights Reserved.