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()

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
© Getstream.io, Inc. All Rights Reserved.