Changeset 75bda38 in Klonkt
- Timestamp:
- 06/25/2026 06:54:59 AM (3 months ago)
- Branches:
- main
- Children:
- f1e0c1f
- Parents:
- abb34d2
- Location:
- src
- Files:
-
- 2 edited
-
routes/activitypub.js (modified) (2 diffs)
-
services/ActivityPubService.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/activitypub.js
rabb34d2 r75bda38 6 6 * GET /ap/users/:slug/outbox OrderedCollection of Create(Note) 7 7 * GET /ap/users/:slug/followers count-only OrderedCollection 8 * GET /ap/users/:slug/featured pinned posts (Mastodon "Featured" tab) 8 9 * GET /ap/notes/:id a single Note 9 10 * POST /ap/users/:slug/inbox, /ap/inbox → 202 (Follow/Accept + signature verify: next step) … … 72 73 }); 73 74 75 // ── Featured (pinned posts → Mastodon "Featured" tab) ───────────── 76 router.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 74 88 // ── Note ────────────────────────────────────────────────────────── 75 89 router.get('/ap/notes/:id', (req, res) => { -
src/services/ActivityPubService.js
rabb34d2 r75bda38 83 83 outbox: `${id}/outbox`, 84 84 followers: `${id}/followers`, 85 featured: `${id}/featured`, 85 86 endpoints: { sharedInbox: `${base}/ap/inbox` }, 86 87 publicKey: { … … 240 241 totalItems: count || 0, 241 242 orderedItems: [], // hidden for privacy; count only 243 }; 244 } 245 246 // Pinned posts → the actor's `featured` collection. Mastodon reads this and shows 247 // these as the "Featured" tab (pinned to the profile). Posts come ordered by pin 248 // rank; embedded as full Notes so a remote server doesn't need extra fetches. 249 export function buildFeatured(base, site, posts) { 250 const id = `${actorId(base, site.slug)}/featured`; 251 const items = (posts || []).map((p) => buildNote(base, site, p)); 252 return { 253 '@context': 'https://www.w3.org/ns/activitystreams', 254 id, 255 type: 'OrderedCollection', 256 totalItems: items.length, 257 orderedItems: items, 242 258 }; 243 259 } … … 968 984 export default { 969 985 getOrCreateKeys, apWants, sendAP, actorId, noteId, 970 buildActor, buildNote, buildCreate, buildOutbox, buildFollowers, 986 buildActor, buildNote, buildCreate, buildOutbox, buildFollowers, buildFeatured, 971 987 followerCount, deliver, fetchActor, verifyRequest, handleInbox, deliverCreate, deliverDelete, deliverUpdate, 972 988 getInteractions, getInteractionById, buildReplyNote, getOutboxNote, deliverReply, resolveRemoteNote,
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)