1
Pinned Posts
Gabriel Kaszewski edited this page 2026-05-29 02:14:24 +00:00

Pinned Posts

k-ap serves GET /users/{id}/featured automatically as an OrderedCollection of pinned post URLs. By default the collection is empty.


Enable pinned posts

Override get_featured_objects in your ApContentReader:

impl ApContentReader for MyDb {
    async fn get_featured_objects(&self, user_id: Uuid) -> anyhow::Result<Vec<Url>> {
        let urls = self.fetch_pinned_post_urls(user_id).await?;
        Ok(urls)
    }

    // ... other required methods
}

Wire up the URL in ApUser

Set featured_url to the endpoint URL so it appears in actor JSON:

ApUser {
    featured_url: Some(
        format!("https://example.com/users/{}/featured", user.id).parse()?
    ),
    // ... other fields
}

k-ap includes featured_url as the featured field in actor JSON. Clients like Mastodon follow this link from the actor's featured field to display pinned posts on a profile.


How it works

GET /users/{id}/featured is registered by service.router(). When a request arrives, k-ap calls ApContentReader::get_featured_objects(user_id) and returns an OrderedCollection with the returned URLs as orderedItems.

The collection is always a flat list of URLs — it does not include the full object JSON. Remote clients fetch each URL individually if they need the content.