Changeset 75bda38 in Klonkt for src/routes


Ignore:
Timestamp:
06/25/2026 06:54:59 AM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
f1e0c1f
Parents:
abb34d2
Message:

feat(fediverse): expose pinned posts via the actor's featured collection

Adds actor.featured + GET /ap/users/:slug/featured (OrderedCollection of pinned,
published, non-fan_only posts as Notes, ordered by pin rank). Mastodon reads this
and shows them under the profile's Featured tab.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/activitypub.js

    rabb34d2 r75bda38  
    66 *   GET /ap/users/:slug/outbox     OrderedCollection of Create(Note)
    77 *   GET /ap/users/:slug/followers  count-only OrderedCollection
     8 *   GET /ap/users/:slug/featured   pinned posts (Mastodon "Featured" tab)
    89 *   GET /ap/notes/:id              a single Note
    910 *   POST /ap/users/:slug/inbox, /ap/inbox  → 202 (Follow/Accept + signature verify: next step)
     
    7273});
    7374
     75// ── Featured (pinned posts → Mastodon "Featured" tab) ─────────────
     76router.get('/ap/users/:slug/featured', (req, res) => {
     77  const site = publicSite(req.params.slug);
     78  if (!site) return res.status(404).end();
     79  const posts = db.prepare(
     80    `SELECT id, slug, title, content, cover_image_url, published_at, created_at
     81     FROM posts WHERE site_id = ? AND status = 'published' AND (fan_only IS NULL OR fan_only = 0)
     82       AND pinned IS NOT NULL AND pinned > 0
     83     ORDER BY pinned ASC, COALESCE(published_at, created_at) DESC LIMIT 20`
     84  ).all(site.id);
     85  AP.sendAP(res, AP.buildFeatured(baseUrl(req), site, posts));
     86});
     87
    7488// ── Note ──────────────────────────────────────────────────────────
    7589router.get('/ap/notes/:id', (req, res) => {
Note: See TracChangeset for help on using the changeset viewer.