Pins

Overview

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

// Pin an activity
PinActivityRequest pinRequest = PinActivityRequest.builder().userID(testUserId).build();

PinActivityResponse response = testFeed.pinActivity(activityId, pinRequest).getData();

// Unpin an activity
UnpinActivityRequest unpinRequest = UnpinActivityRequest.builder().UserID(testUserId).build();

testFeed.unpinActivity(activityId, unpinRequest);

When you read a feed pinned activities are automatically returned:

GetOrCreateFeedResponse response = feed.getOrCreate(GetOrCreateFeedRequest.builder()
    .userID("sara")
    .build()).getData();
System.out.println(response.getPinnedActivities());

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.

QueryPinnedActivitiesResponse response = feeds.queryPinnedActivities("user", "john",
    QueryPinnedActivitiesRequest.builder()
        .includeModeratedActivities(true)
        .includeExpiredActivities(true)
        .limit(20)
        .build()).execute().getData();
System.out.println(response.getPinnedActivities() + " " + response.getNext());

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