await serverClient.feeds.createFeedView({
id: "<view id>",
activity_selectors: [
{
type: "following",
},
],
ranking: { type: "recency" },
});Feed views
When to use feed views
Feed groups let you define what activities should be included in the feed and the ranking to sort these activities.
By default all feeds in the given group will have the same settings. However, you might want to experiment with different selectors and rankings. Feed views let you do that by overriding the group's default settings.
Note that any write operation to feed groups/views can take up to 30 seconds to propagate to all API nodes.
Applications can't have more than 100 feed views
Feed view operations are only available on server-side.
viewId := "myview"
_, err = client.Feeds().CreateFeedView(context.Background(), &getstream.CreateFeedViewRequest{
ID: viewId,
ActivitySelectors: []getstream.ActivitySelectorConfig{
{
Type: getstream.PtrTo("following"),
},
},
Ranking: &getstream.RankingConfig{
Type: getstream.PtrTo("recency"),
},
})
if err != nil {
log.Fatal("Error creating feed view:", err)
}Alternatively you can use the getOrCreateFeedView endpoint that will create and apply settings, or return the existing view.
_, err = feed.GetOrCreate(context.Background(), &getstream.GetOrCreateFeedRequest{
View: getstream.PtrTo("<view id>"),
UserID: getstream.PtrTo("<user id>"),
})
if err != nil {
log.Fatal("Error:", err)
}With custom feed views you can control
- Activity selectors
- Ranking
- Aggregation
List feed views
To list existing feed views and their configurations:
response, err := client.Feeds().ListFeedViews(context.Background(), &getstream.ListFeedViewsRequest{})
if err != nil {
log.Fatal("Error listing feed views:", err)
}Updating feed views
It's possible to update any custom or built-in feed views.
_, err = client.Feeds().UpdateFeedView(context.Background(), viewId, &getstream.UpdateFeedViewRequest{
// Fields to update
})
if err != nil {
log.Fatal("Error:", err)
}Deleting feed views
_, err = client.Feeds().DeleteFeedView(context.Background(), viewId, &getstream.DeleteFeedViewRequest{})