Changes in src/routes/activitypub.js [1e172f3:fa33214] in Klonkt
- File:
-
- 1 edited
-
src/routes/activitypub.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/activitypub.js
r1e172f3 rfa33214 253 253 } 254 254 queueRoute('offers', (id, slug, me) => Guardianship.offersCollection(id, slug, me)); 255 queueRoute('follows', (id , slug, me) => Guardianship.followsCollection(id, slug, me));255 queueRoute('follows', (id) => Guardianship.followsCollection(id)); 256 256 // §5.3 turned around (shaer-p729): what this ward has asked to follow, still 257 257 // waiting on its guardians. Owner-only like the rest — who a child wants to … … 268 268 // they follow) as Create(Note) items, so an app (Shaer) can build a unified 269 269 // feed. Anyone else gets 403; the inbox stays write-only for the public. 270 router.get('/ap/users/:slug/inbox', async(req, res) => {270 router.get('/ap/users/:slug/inbox', (req, res) => { 271 271 const auth = OAuth.verifyBearer(req.headers.authorization); 272 272 if (!auth || auth.site.slug !== req.params.slug) return res.status(403).end(); 273 273 const base = baseUrl(req); 274 // Wachten is een UITBREIDING van deze lezing, geen tweede endpoint (shaer-n05).275 // Geef `since` (de shaer:cursor van je vorige antwoord) en `wait` mee, en het276 // antwoord blijft hangen tot er iets is of de tijd om is. Zonder die twee277 // gedraagt de route zich exact zoals altijd.278 //279 // Bewust hetzelfde antwoord in plaats van een "er is nieuws"-seintje: dan280 // hoeft er niets nieuws geparsed te worden, is er geen tweede beschrijving van281 // de kaartvorm die uit de pas kan lopen, en scheelt het de client een tweede282 // ronde.283 const wachtS = Math.min(Math.max(parseInt(req.query.wait, 10) || 0, 0), 50);284 if (req.query.since && wachtS > 0) {285 const afbreken = new AbortController();286 res.on('close', () => afbreken.abort()); // client hing op: niet doorgaan met wachten287 const uit = await AP.waitForFeedChange(auth.site.slug, {288 since: String(req.query.since), waitMs: wachtS * 1000, signal: afbreken.signal,289 });290 if (res.writableEnded || afbreken.signal.aborted) return undefined;291 // Niets veranderd? Dan een LEEG antwoord (Barts punt): de hele collectie292 // terugsturen terwijl er niets gebeurd is, is elke 25 seconden een tijdlijn293 // over de mobiele verbinding voor niets. Met 304 kost stilte niets en kost294 // nieuws nog steeds maar één rondje -- beter dan een apart seintje-endpoint,295 // dat voor nieuws twee rondjes nodig heeft.296 //297 // De '0'-uitzondering is geen franje. Ontbreekt ap_feed_state (een instance298 // die de migratie nog niet draaide), dan geeft feedCursor altijd '0' terug,299 // en zou een client hier eeuwig 304 krijgen en nooit meer inhoud zien. Bij300 // een lege merksteen sturen we dus gewoon de collectie.301 if (!uit.changed && uit.cursor !== '0') {302 res.set('Vary', 'Authorization');303 return res.status(304).end();304 }305 }306 274 // Gated feature (FEP-633c): may this account see EXTERNAL embeds? A ward's 307 275 // world outside the fediverse is the guardians' call. The gate is applied … … 317 285 const playbackAllowed = embedsAllowed 318 286 && Guardianship.externalPlaybackAllowed(auth.site.external_playback, isWard); 319 const rows = AP.getTimeline(auth.site.slug, 60); 320 // Eén query voor de hele pagina (shaer-9e9 fase 2): shaer:liked komt uit de 321 // tussentabel, de bron van waarheid, en niet meer uit de afgeleide kolom op 322 // ap_timeline. Per rij vragen zou hier een N+1 opleveren. 323 const reacties = AP.getReactionsFor(auth.site.slug, rows.map((t) => t.id)); 324 const posts = rows.map((t) => ({ 287 const posts = AP.getTimeline(auth.site.slug, 60).map((t) => ({ 325 288 id: `${t.id}#create`, 326 289 type: 'Create', … … 370 333 // Whether THIS account already liked/boosted the note, so the app's 371 334 // detail-view buttons show the current state (and can toggle/undo). 372 'shaer:liked': !! (reacties.get(t.id) || {}).liked,373 'shaer:boosted': !! (reacties.get(t.id) || {}).boosted,335 'shaer:liked': !!t.liked, 336 'shaer:boosted': !!t.boosted, 374 337 // An external (non-fediverse) embed, thumbnail-only and never an iframe. 375 338 // Omitted entirely when the gate is closed (see above). … … 476 439 'shaer:externalLinks': playbackAllowed, 477 440 }, 478 // Het merk van wat hierin zit. Geef hem terug als `since` om op het479 // volgende te wachten. NA het samenstellen bepaald, zodat hij precies dekt480 // wat je in handen hebt en niet iets dat er ondertussen bij kwam.481 'shaer:cursor': AP.feedCursor(auth.site.slug),482 441 totalItems: items.length, 483 442 orderedItems: items, 484 443 }); 485 return undefined;486 444 }); 487 445
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)