// Add a reaction to an activity
let reaction = try await feed.addReaction(
activityId: "activity_123",
request: .init(
custom: ["emoji": "❤️"],
type: "like"
)
)
// Remove a reaction
_ = try await feed.deleteReaction(activityId: "activity_123", type: "like")
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.
// Add a reaction to an activity
val reaction: Result<FeedsReactionData> = feed.addReaction(
activityId = "activity_123",
request = AddReactionRequest(
custom = mapOf("emoji" to "❤️"),
type = "like"
)
)
// Remove a reaction
val deleteResult: Result<FeedsReactionData> = feed.deleteReaction(
activityId = "activity_123",
type = "like"
)
// Add a reaction to an activity
const addResponse = await client.addReaction({
activity_id: "activity_123",
type: "like",
custom: {
emoji: "❤️",
},
});
console.log(addResponse.reaction);
// Adding a reaction without triggering push notifications
await client.addReaction({
activity_id: "activity_123",
type: "like",
custom: {
emoji: "❤️",
},
skip_push: true,
});
// Add a reaction to a comment
await client.addCommentReaction({
comment_id: "comment_456",
type: "like",
custom: {
emoji: "👍",
},
});
// Adding a comment reaction without triggering push notifications
await client.addCommentReaction({
comment_id: "comment_456",
type: "like",
custom: {
emoji: "👍",
},
skip_push: true,
});
const deleteResponse = await client.deleteActivityReaction({
activity_id: "activity_123",
type: "like",
});
console.log(deleteResponse.reaction);
// Add a reaction to an activity
final reaction = await feed.addReaction(
activityId: 'activity_123',
request: const AddReactionRequest(custom: {'emoji': '❤️'}, type: 'like'),
);
// Remove a reaction
await feed.deleteReaction(activityId: 'activity_123', type: 'like');
// Add a reaction to an activity
const addResponse = await client.feeds.addReaction({
activity_id: "activity_123",
type: "like",
custom: {
emoji: "❤️",
},
user_id: "reacting_user_id",
});
console.log(addResponse.reaction);
// Adding a reaction without triggering push notifications
await client.feeds.addReaction({
activity_id: "activity_123",
type: "like",
custom: {
emoji: "❤️",
},
user_id: "reacting_user_id",
skip_push: true,
});
// Add a reaction to a comment
await client.feeds.addCommentReaction({
comment_id: "comment_456",
type: "like",
custom: {
emoji: "👍",
},
user_id: "reacting_user_id",
});
// Adding a comment reaction without triggering push notifications
await client.feeds.addCommentReaction({
comment_id: "comment_456",
type: "like",
custom: {
emoji: "👍",
},
user_id: "reacting_user_id",
skip_push: true,
});
const deleteResponse = await client.feeds.deleteActivityReaction({
activity_id: "activity_123",
type: "like",
user_id: "reacting_user_id",
});
console.log(deleteResponse.reaction);
// Add a reaction to an activity
_, err = client.Feeds().AddReaction(context.Background(), activityID, &getstream.AddReactionRequest{
Type: "like",
Custom: map[string]interface{}{
"emoji": "❤️",
},
UserID: getstream.PtrTo("john"),
})
if err != nil {
log.Fatal("Error adding reaction:", err)
}
// Adding a reaction without triggering push notifications
_, err = client.Feeds().AddReaction(context.Background(), activityID, &getstream.AddReactionRequest{
Type: "like",
Custom: map[string]interface{}{
"emoji": "❤️",
},
UserID: getstream.PtrTo("john"),
SkipPush: getstream.PtrTo(true),
})
if err != nil {
log.Fatal("Error adding reaction without push:", err)
}
// Add a reaction to a comment
_, err = client.Feeds().AddCommentReaction(context.Background(), commentID, &getstream.AddCommentReactionRequest{
Type: "like",
Custom: map[string]interface{}{
"emoji": "👍",
},
UserID: getstream.PtrTo("john"),
})
if err != nil {
log.Fatal("Error adding comment reaction:", err)
}
// Adding a comment reaction without triggering push notifications
_, err = client.Feeds().AddCommentReaction(context.Background(), commentID, &getstream.AddCommentReactionRequest{
Type: "like",
Custom: map[string]interface{}{
"emoji": "👍",
},
UserID: getstream.PtrTo("john"),
SkipPush: getstream.PtrTo(true),
})
if err != nil {
log.Fatal("Error adding comment reaction without push:", err)
}
// Delete activity reaction
_, err = client.Feeds().DeleteActivityReaction(context.Background(), activityID, "like", &getstream.DeleteActivityReactionRequest{
UserID: getstream.PtrTo("john"),
})
if err != nil {
log.Fatal("Error deleting activity reaction:", err)
}
AddReactionRequest reactionRequest =
AddReactionRequest.builder().type("like").userID(testUserId).build();
AddReactionResponse response =
feeds.addReaction(activityId, reactionRequest).execute().getData();
$response = $this->feedsV3Client->addReaction(
$activityId,
new GeneratedModels\AddReactionRequest(
type: 'like',
userID: $this->testUserId
)
);
var response = await _feedsV3Client.AddReactionAsync(
activityId,
new AddReactionRequest
{
Type = "like",
UserID = _testUserId
}
);
response = self.client.feeds.add_reaction(
activity_id, type="like", user_id=self.test_user_id
)
By default creating a reaction doesn’t create an activity.
When you read a feed the reactions are included. Here’s an example:
let feedData = try await feed.getOrCreate()
// Last 15 reactions on the first activity
print(feed.state.activities[0].latestReactions)
// Count of reactions by type
print(feed.state.activities[0].reactionGroups)
feed.getOrCreate()
feed.state.activities.collect { activities ->
// Last 15 reactions on the first activity
println(activities.first().latestReactions)
// Count of reactions by type
println(activities.first().reactionGroups)
}
const feed = client.feed("user", "sara");
await feed.getOrCreate();
console.log(feed.state.getLatestValue().activities?.[0].own_reactions);
console.log(feed.state.getLatestValue().activities?.[0].latest_reactions);
console.log(feed.state.getLatestValue().activities?.[0].reaction_groups);
final feedData = await feed.getOrCreate();
// Last 15 reactions on the first activity
print(feed.state.activities[0].latestReactions);
// Count of reactions by type
print(feed.state.activities[0].reactionGroups);
const feed = client.feeds.feed("user", "sara");
const response = await feed.getOrCreate({ user_id: "sara" });
console.log(response.activities[0].own_reactions);
console.log(response.activities[0].latest_reactions);
console.log(response.activities[0].reaction_groups);
feed := client.Feeds().Feed("user", "john")
feedResponse, err := feed.GetOrCreate(context.Background(), &getstream.GetOrCreateFeedRequest{
UserID: getstream.PtrTo("john"),
})
fmt.Println(feedResponse.Data.Activities[0].OwnReactions)
fmt.Println(feedResponse.Data.Activities[0].LatestReactions)
fmt.Println(feedResponse.Data.Activities[0].ReactionGroups)
Map<String, Object> filter = new HashMap<>();
filter.put("reaction_type", "like");
QueryActivityReactionsRequest queryRequest =
QueryActivityReactionsRequest.builder().limit(10).filter(filter).build();
QueryActivityReactionsResponse response =
feeds.queryActivityReactions(activityId, queryRequest).execute().getData();
$response = $this->feedsV3Client->queryActivityReactions(
$activityId,
new GeneratedModels\QueryActivityReactionsRequest(
limit: 10,
filter: (object)['reaction_type' => 'like']
)
);
var response = await _feedsV3Client.QueryActivityReactionsAsync(
activityId,
new QueryActivityReactionsRequest
{
Limit = 10,
Filter = new Dictionary<string, object> { ["reaction_type"] = "like" }
}
);
response = self.client.feeds.query_activity_reactions(
activity_id, limit=10, filter={"type": "like"}
)
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
name | type | description | supported operations | example |
---|---|---|---|---|
reaction_type | string or list of strings | The type of reaction | $in , $eq | { reaction_type: { $in: [ 'like', 'heart', 'thumbs_up' ] } } |
user_id | string or list of strings | The ID of the user who created the reaction | $in , $eq | { user_id: { $eq: 'user_123' } } |
created_at | string, must be formatted as an RFC3339 timestamp | The time the reaction was created | $eq , $gt , $gte , $lt , $lte | { created_at: { $gte: '2023-12-04T09:30:20.45Z' } } |