Changeset 30871c1 in Klonkt for src/routes/activitypub.js
- Timestamp:
- 07/20/2026 11:35:45 PM (7 weeks ago)
- Branches:
- main
- Children:
- 562e1b0
- Parents:
- 5143ccf
- git-author:
- Robin <roboburr@…> (07/20/2026 11:35:44 PM)
- git-committer:
- Robin <roboburr@…> (07/20/2026 11:35:45 PM)
- File:
-
- 1 edited
-
src/routes/activitypub.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/activitypub.js
r5143ccf r30871c1 169 169 // URIs so their own client can build a friends list; everyone else gets the 170 170 // count only (privacy). 171 // FEP-9876: enrichment is opt-in via `Prefer: return=representation` (RFC 7240). 172 // Returns true and sets the response headers when the owner asked for it. 173 function wantsEnriched(req, res) { 174 res.set('Vary', 'Prefer'); // enriched and bare are two representations 175 if (AP.prefersEnriched(req.get('Prefer'))) { 176 res.set('Preference-Applied', 'return=representation'); 177 return true; 178 } 179 return false; 180 } 181 171 182 router.get('/ap/users/:slug/followers', (req, res) => { 172 183 const auth = OAuth.verifyBearer(req.headers.authorization); … … 176 187 if (owner) { 177 188 const uris = db.prepare('SELECT actor_uri FROM ap_followers WHERE slug = ? ORDER BY created_at').all(site.slug).map((r) => r.actor_uri); 178 const items = uris.map((u) => AP.buildActorRef(site.slug, u)); // name + avatar (shaer-aa3) 189 // Default = bare references; enrich only when the client asks (FEP-9876). 190 const items = wantsEnriched(req, res) ? uris.map((u) => AP.buildActorRef(site.slug, u)) : uris; 179 191 return AP.sendAP(res, AP.buildFollowers(baseUrl(req), site, items.length, items)); 180 192 } … … 190 202 if (!site) return res.status(404).end(); 191 203 if (owner) { 204 const enrich = wantsEnriched(req, res); // FEP-9876 opt-in 192 205 let items = []; 193 try { items = db.prepare("SELECT actor_uri FROM ap_following WHERE slug = ? AND status = 'accepted' ORDER BY created_at").all(site.slug).map((r) => AP.buildActorRef(site.slug, r.actor_uri)); } catch { /* table may not exist */ } 206 try { 207 const uris = db.prepare("SELECT actor_uri FROM ap_following WHERE slug = ? AND status = 'accepted' ORDER BY created_at").all(site.slug).map((r) => r.actor_uri); 208 items = enrich ? uris.map((u) => AP.buildActorRef(site.slug, u)) : uris; 209 } catch { /* table may not exist */ } 194 210 return AP.sendAP(res, AP.buildFollowing(baseUrl(req), site, items.length, items)); 195 211 }
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)