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

Follows

Follow & Unfollow

// Follow a user
val timeline = client.feed(group = "timeline", id = "john")
timeline.follow(FeedId(group = "user", id = "tom"))

// Follow a stock
timeline.follow(FeedId(group = "stock", id = "apple"))

// Follow with more fields
timeline.follow(
    targetFid = FeedId(group = "stock", id = "apple"),
    custom = mapOf("reason" to "investment")
)

Querying Follows

// Do I follow a list of feeds
// My feed is timeline:john
val followQuery = FollowsQuery(
    filter = Filters.and(
        Filters.equal("source_feed", "timeline:john"),
        Filters.`in`("target_feed", listOf("user:sara", "user:adam"))
    )
)
val followList = client.followList(query = followQuery)
val page1: Result<List<FollowData>> = followList.get()
val page2: Result<List<FollowData>> = followList.queryMoreFollows()
val page1And2 = followList.state.follows

// Paginating through followers for a feed
// My feed is timeline:john
val followerQuery = FollowsQuery(
    filter = Filters.equal("target_feed", "timeline:john")
)
val followerList = client.followList(query = followerQuery)
val followerPage1: Result<List<FollowData>> = followerList.get()

Follows Queryable Built-In Fields

nametypedescriptionsupported operationsexample
source_feedstring or list of stringsThe feed ID that is following$in, $eq{ source_feed: { $eq: 'messaging:general' } }
target_feedstring or list of stringsThe feed ID being followed$in, $eq{ target_feed: { $in: [ 'sports:news', 'tech:updates' ] } }
statusstring or list of stringsThe follow status$in, $eq{ status: { $in: [ 'accepted', 'pending', 'rejected' ] } }
created_atstring, must be formatted as an RFC3339 timestampThe time the follow relationship was created$eq, $gt, $gte, $lt, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }

Follow Requests

Some apps require the user’s approval for following them.

// Sara needs to configure the feed with visibility = followers for enabling follow requests
val saraFeed = saraClient.feed(
    query = FeedQuery(
        group = "user",
        id = "sara",
        data = FeedInputData(visibility = FeedVisibility.Followers)
    )
)
saraFeed.getOrCreate()

// Adam requesting to follow the feed
val adamTimeline = adamClient.feed(group = "timeline", id = "adam")
adamTimeline.getOrCreate()

val followRequest = adamTimeline.follow(saraFeed.fid) // user:sara
println(followRequest.getOrNull()?.status) // FollowStatus.PENDING

// Sara accepting
saraFeed.acceptFollow(
    sourceFid = adamTimeline.fid, // timeline:adam
    role = "feed_member" // optional
)
// or rejecting the request
saraFeed.rejectFollow(adamTimeline.fid) // timeline:adam

Push Preferences on Follow

When following a feed, you can set push_preference to control push notifications for future activities from that feed:

  • all - Receive push notifications for all activities from the followed feed
  • none (default) - Don’t receive push notifications for activities from the followed feed

Note: The push_preference parameter controls future notifications from the followed feed, while skip_push controls whether the follow action itself triggers a notification.

Examples: Push Preferences vs Skip Push

Understanding the difference between push_preference and skip_push:

// Scenario 1: Follow a user and receive notifications for their future activities
await timeline.follow("user:alice", {
  push_preference: "all", // You'll get push notifications for Alice's future posts
});

// Scenario 2: Follow a user but don't get notifications for their activities
await timeline.follow("user:bob", {
  push_preference: "none", // You won't get push notifications for Bob's future posts
});

// Scenario 3: Follow a user silently
await timeline.follow("user:charlie", {
  skip_push: true, // Charlie won't get a "you have a new follower" notification
  push_preference: "all", // But you'll still get notifications for Charlie's future posts
});

// Scenario 4: Silent follow with no future notifications
await timeline.follow("user:diana", {
  skip_push: true, // Diana won't know you followed her
  push_preference: "none", // And you won't get notifications for her posts
});
© Getstream.io, Inc. All Rights Reserved.