Changeset 61d52ed in Klonkt for src/routes/activitypub.js
- Timestamp:
- 10/14/2026 04:25:21 PM (6 hours ago)
- Branches:
- main
- Parents:
- 6e9bc70
- git-author:
- Bart <bart@…> (10/14/2026 04:23:29 PM)
- git-committer:
- Bart <bart@…> (10/14/2026 04:25:21 PM)
- File:
-
- 1 edited
-
src/routes/activitypub.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/activitypub.js
r6e9bc70 r61d52ed 1411 1411 }); 1412 1412 1413 // De poorten op één vreemde note, voor de thread en voor de losse note: 1414 // beeld, muziek, video en emoji, per verzoek en buiten elke cache om. De 1415 // emoji-poort knipt in de byline zelf: FEP-9098 zit in de tag van de 1416 // ingesloten actor, niet meer in een eigen emoji-kaart ernaast. 1417 function readerGates(site, isWard) { 1418 const gate = (col) => Guardianship.wardGateAllowed(site[col], isWard); 1419 const images = gate('gate_images'), audio = gate('gate_music'), video = gate('gate_video'); 1420 const emoji = gate('gate_custom_emoji'); 1421 return (n) => ({ 1422 ...n, 1423 attachment: AP.gateAttachments(n.attachment, { images, audio, video }), 1424 tag: emoji ? n.tag : AP.stripEmojiTags(n.tag), 1425 attributedTo: (!emoji && n.attributedTo && typeof n.attributedTo === 'object') 1426 ? { ...n.attributedTo, tag: undefined } : n.attributedTo, 1427 }); 1428 } 1429 1413 1430 // ── De thread onder een post (shaer-tqz): ophalen, niet bewaren ──── 1414 1431 // … … 1446 1463 // poorten als de tijdlijn -- per verzoek, buiten de threadcache om. 1447 1464 const threadsOpen = Guardianship.wardGateAllowed(auth.site.external_threads, isWard); 1448 const gate2 = (col) => Guardianship.wardGateAllowed(auth.site[col], isWard);1449 1465 const kring = threadsOpen ? { notes: uit.notes, hidden: 0 } : AP.filterThreadToCircle(auth.site.slug, uit.notes); 1450 const imagesOk = gate2('gate_images'), musicOk = gate2('gate_music'), emojiOk = gate2('gate_custom_emoji'); 1451 const videoOk = gate2('gate_video'); 1452 uit.notes = kring.notes.map((n) => ({ 1453 ...n, 1454 attachment: AP.gateAttachments(n.attachment, { images: imagesOk, audio: musicOk, video: videoOk }), 1455 tag: emojiOk ? n.tag : AP.stripEmojiTags(n.tag), 1456 // De emoji-poort knipt in de byline zelf: FEP-9098 zit in de tag van de 1457 // ingesloten actor, niet meer in een eigen emoji-kaart ernaast. 1458 attributedTo: (!emojiOk && n.attributedTo && typeof n.attributedTo === 'object') 1459 ? { ...n.attributedTo, tag: undefined } : n.attributedTo, 1460 })); 1466 uit.notes = kring.notes.map(readerGates(auth.site, isWard)); 1461 1467 uit.hidden = kring.hidden; 1462 1468 // Liked/boosted per antwoord, BUITEN de cache om: de genormaliseerde notes … … 1481 1487 }); 1482 1488 1489 // ── Eén note, voor wie een gesprek naar boven volgt ──────────────── 1490 // 1491 // De thread hierboven geeft wat onder een post hangt; dit geeft de post zelf. 1492 // Een lezer die een antwoord kreeg en de ouder niet, kan die ouder bij een 1493 // server in secure mode alleen ondertekend halen, en de sleutel staat hier. 1494 // Bearer-only en niets bewaren, net als de thread. Dezelfde weigering-of- 1495 // storing en dezelfde poorten; voor een ward met een dichte kring is een note 1496 // van buiten de kring er niet, en dat wordt gezegd in plaats van verzwegen. 1497 router.get('/ap/users/:slug/object', async (req, res) => { 1498 const auth = OAuth.verifyBearer(req.headers.authorization); 1499 if (!auth || auth.site.slug !== req.params.slug) return res.status(403).end(); 1500 const objectUri = String(req.query.uri || ''); 1501 if (!/^https:\/\//i.test(objectUri)) return res.status(400).json({ error: 'uri must be an https URI' }); 1502 const uit = await AP.getObject(auth.site.slug, objectUri); 1503 if (!uit.found) { 1504 const geweigerd = [401, 403, 404, 410].includes(uit.sourceStatus); 1505 return res.status(geweigerd ? 404 : 502) 1506 .json({ error: geweigerd ? 'not shared by source' : 'source unreachable', sourceStatus: uit.sourceStatus || undefined }); 1507 } 1508 const isWard = (() => { try { return Guardianship.listGuardians(auth.site.slug).length > 0; } catch { return false; } })(); 1509 const threadsOpen = Guardianship.wardGateAllowed(auth.site.external_threads, isWard); 1510 if (!threadsOpen && !AP.filterThreadToCircle(auth.site.slug, [uit.note]).notes.length) { 1511 return res.status(404).json({ error: 'outside the circle', 'shaer:hidden': 1 }); 1512 } 1513 AP.sendAP(res, { '@context': AP.AP_CONTEXT, ...readerGates(auth.site, isWard)(uit.note) }, 'private, no-store'); 1514 }); 1515 1483 1516 router.get('/ap/notes/:id/replies', (req, res) => { 1484 1517 const base = baseUrl(req);
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)