Python
Reactions and Feeds
Confused about "Reactions and Feeds"?
Let us know how we can improve our documentation:
LAST EDIT Jan 26 2021
Read Feeds with Reactions
Copied!Confused about "Read Feeds with Reactions"?
Let us know how we can improve our documentation:
When using reactions, it is possible to request enriched activities that include both attached reactions by type and reaction counters.
Listed below are the parameters for retrieving reactions.
Parameters
Copied!Confused about "Parameters"?
Let us know how we can improve our documentation:
name | type | description | default | optional |
---|---|---|---|---|
recent | boolean | Include the 10 most recent reactions to activities. | - | ✓ |
own | boolean | Include the current user's reaction to activities. | - | ✓ |
counts | boolean | Include the total count of reaction (by kind) to activities. | - | ✓ |
1
2
3
4
5
6
7
8
9
// read bob's timeline and include most recent reactions to all activities and their total count
client.feed('timeline', 'bob').get({
reactions: { recent: true, counts: true }
});
// read bob's timeline and include most recent reactions to all activities and her own reactions
client.feed('timeline', 'bob').get({
reactions: { own: true, recent: true, counts: true }
});
1
2
3
4
5
6
7
# read bob's timeline and include most recent reactions to all activities and their total count
client.feed("timeline", "bob").get(reactions={"recent": True, "counts": True})
# read bob's timeline and include most recent reactions to all activities and her own reactions
client.feed("timeline", "bob").get(
reactions={"own": True, "recent": True, "counts": True}, user_id="bob"
)
1
2
3
4
5
6
7
8
# read bob's timeline and include most recent reactions to all activities and their total count
client.feed("timeline", "bob").get(reactions: {recent: true, counts: true})
# read bob's timeline and include most recent reactions to all activities and her own reactions
client.feed("timeline", "bob").get(
reactions: {own: true, recent: true, counts: true},
user_id: "bob"
)
1
2
3
4
5
// read bob's timeline and include most recent reactions to all activities and their total count
$client->feed("timeline", "bob")->getActivities(0, 5, null, true, ["recent"=>true, "counts"=>true]);
// read bob's timeline and include most recent reactions to all activities and her own reactions by passing the user_id in the `options` array
$client->feed("timeline", "bob")->getActivities(0, 5, ["user_id" => "bob"], true, ["recent"=>true, "counts"=>true]);
1
2
3
4
5
6
7
8
9
10
11
12
// read bob's timeline and include most recent reactions to all activities and their total count
client.flatFeed("timeline", "bob")
.getEnrichedActivities(new EnrichmentFlags()
.withRecentReactions()
.withReactionCounts()).get();
// read bob's timeline and include most recent reactions to all activities and her own reactions
client.flatFeed("timeline", "bob")
.getEnrichedActivities(new EnrichmentFlags()
.withOwnReactions()
.withRecentReactions()
.withReactionCounts()).get();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// read bob's timeline and include most recent reactions to all activities and their total count
opts := []stream.GetActivitiesOption{
stream.WithEnrichRecentReactions(),
stream.WithEnrichReactionCounts(),
}
client.FlatFeed("timeline", "bob").GetEnrichedActivities(opts...)
// read bob's timeline and include most recent reactions to all activities and her own reactions
opts := []stream.GetActivitiesOption{
stream.WithEnrichOwnReactions(),
stream.WithEnrichRecentReactions(),
stream.WithEnrichReactionCounts(),
}
client.FlatFeed("timeline", "bob").GetEnrichedActivities(opts...)
1
2
3
4
5
6
7
// read bob's timeline and include most recent reactions to all activities and their total count
client.flatFeed(feedSlug: "timeline", userId: "bob")
.get(includeReactions: [.latest, .counts]) { result in /* ... */ }
// read bob's timeline and include most recent reactions to all activities and her own reactions
client.flatFeed(feedSlug: "timeline", userId: "bob")
.get(includeReactions: [.own, .latest, .counts]) { result in /* ... */ }
1
2
3
4
5
// read bob's timeline and include most recent reactions to all activities and their total count
await client.Feed("timeline", "bob").GetEnrichedFlatActivities(GetOptions.Default.WithReaction(ReactionOption.With().Recent().Counts()));
// read bob's timeline and include most recent reactions to all activities and her own reactions
await client.Feed("timeline", "bob").GetEnrichedFlatActivities(GetOptions.Default.WithReaction(ReactionOption.With().Recent().Own()));
Notify Other Feeds
Copied!Confused about "Notify Other Feeds"?
Let us know how we can improve our documentation:
When adding a reaction, you can use the target_feeds
parameter to notify a list of users about the new reaction. When specified, all targeted feeds will receive an activity containing a reference to the reaction.
1
2
3
4
5
// adds a comment reaction to the activity and notifies Thierry's notification feed
client.reactions.add("comment", activityId,
{ text: "@thierry great post!" },
{ targetFeeds: ["notification:thierry"] }
);
1
2
3
4
5
6
7
8
# adds a comment reaction to the activity and notifies Thierry's notification feed
client.reactions.add(
"comment",
activity_id,
user_id="mike",
data={"text": "@thierry great post!"},
target_feeds=["notification:thierry"],
)
1
2
3
4
5
6
7
8
# adds a comment reaction to the activity and notifies Thierry's notification feed
client.reactions.add(
"comment",
activity_id,
"mike",
data: {text: "@thierry great post!"},
target_feeds: ["notification:thierry"],
)
1
2
3
4
5
6
7
8
// adds a comment reaction to the activity and notifies Thierry's notification feed
$client->reactions()->add(
"comment",
$activity_id,
"mike",
["text" => "@thierry great post!"],
["notification:thierry"],
);
1
2
3
4
5
6
7
8
Reaction comment = new Reaction.Builder()
.kind("comment")
.activityID(activity.getID())
.extraField("text", "@thierry great post!")
.build();
// adds a comment reaction to the activity and notifies Thierry's notification feed
client.reactions().add("john-doe", comment, new FeedID("notification:thierry")).join();
1
2
3
4
5
6
7
8
9
10
11
// adds a comment reaction to the activity and notifies Thierry's notification feed
r := stream.AddReactionRequestObject{
Kind: "comment",
ActivityID: activityID,
UserID: "bob",
Data: map[string]interface{}{
"text": "@thierry great post!",
},
TargetFeeds: []string{"notification:thierry"},
}
result, err := client.Reactions().Add(r)
1
2
3
4
5
// adds a comment reaction to the activity and notifies Thierry's notification feed
client.add(reactionTo: activityId,
kindOf: "comment",
extraData: Comment(text: "@thierry great post!"),
targetsFeedIds: [FeedId(feedSlug: "notification", userId: "thierry")]) { result in /* ... */ }
1
2
3
4
5
6
7
// adds a comment reaction to the activity and notifies Thierry's notification feed
var reactionData = new Dictionary<string, object="">()
{
{ "text", "@thierry great post!"},
};
var feedsToNotify = new string[] { "notification:thierry" };
await client.Reactions.Add("comment", activityId, "bob", reactionData, feedsToNotify);</string,>