Pins

Overview

Sometimes you'll want to pin your favorite activity to a feed. You can pin an activity like this:

_, err = client.Feeds().PinActivity(context.Background(), feedGroupID, feedID, activityID, &getstream.PinActivityRequest{
  UserID: getstream.PtrTo("john"),
})

if err != nil {
  log.Fatal("Error pinning activity:", err)
}

When you read a feed pinned activities are automatically returned:

_, err = client.Feeds().UnpinActivity(context.Background(), feedGroupID, feedID, activityID, &getstream.UnpinActivityRequest{
  UserID: getstream.PtrTo("john"),
})
if err != nil {
  log.Fatal("Error unpinning activity:", err)
}

Query pinned activities

queryPinnedActivities returns the pinned activities of a feed, with filtering, sorting and pagination. It applies the same read rules as querying activities:

  • shadowed and expired activities are returned only to their author
  • removed and soft-deleted activities are not returned
  • private activities are returned only to their author, and to server-side requests without a user
  • activities authored by a user blocked in either direction are not returned

A pin whose activity is hidden is left out of the response, so a page can contain fewer items than limit, or none, while next is still set. Paginate on next, not on the page size.

Server-side requests can pass user_id to read the pins as that user sees them. The feed read permission is still checked as a server-side request.

Server-side requests without a user can include hidden pins:

  • include_moderated_activities: shadowed and removed activities
  • include_soft_deleted_activities: soft-deleted activities
  • include_expired_activities: expired activities
Warning:

These flags are server-side only. Client-side requests ignore them, and a request that also sets user_id or user is rejected.

response, err := client.Feeds().QueryPinnedActivities(context.Background(), "user", "john", &getstream.QueryPinnedActivitiesRequest{
  IncludeModeratedActivities: getstream.PtrTo(true),
  IncludeExpiredActivities:   getstream.PtrTo(true),
  Limit:                      getstream.PtrTo(20),
})

GetOrCreateFeed returns pinned activities too (pinned_activities), but does not apply these rules.