Changeset e84ce32 in Klonkt for src/routes/posts.js
- Timestamp:
- 07/24/2026 05:34:51 PM (7 weeks ago)
- Branches:
- main
- Children:
- 1a2d8ac
- Parents:
- 318d0c2
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r318d0c2 re84ce32 20 20 import VideoCoverService from '../services/VideoCoverService.js'; 21 21 import ActivityPubService from '../services/ActivityPubService.js'; 22 import * as Guardianship from '../services/guardianship/index.js'; 22 23 import { premiumUnlocked } from '../services/PatreonService.js'; 23 24 import { defaultMinCents as paidDefaultMinCents, patreonUrl as paidPatronUrl } from '../services/PaidPatreonService.js'; … … 930 931 return renderPage(req, res, 'partials/messages-append', { items, seen: seenAt, hasMore, nextOffset: offset + FEED_PAGE, moreBase }); 931 932 } 933 // FEP-633c: pending guardianship offers TO this account (ward side) show 934 // as a special message with an accept button (Robins besluit: the kid 935 // answers in their own Klonkt; safety is handled out-of-band by the 936 // guardians themselves). 937 const guardianOffers = site 938 ? Guardianship.listOffers(site.slug).filter((o) => o.role === 'ward') 939 : []; 932 940 renderPage(req, res, 'pages/messages', { 933 941 pageTitleKey: 'msg.title', bodyClass: 'on-special', items, seenAt, 934 hasMore, nextOffset: offset + FEED_PAGE, moreBase, 942 hasMore, nextOffset: offset + FEED_PAGE, moreBase, guardianOffers, 935 943 success: req.query.success || null, error: req.query.error || null, 936 944 }); 945 }); 946 947 // The kid answers a guardianship offer from Berichten: the same C2S 948 // Accept/Reject pipeline the Shaer apps use (one path, one behavior). 949 router.post('/messages/guardianship', requireSiteManager, async (req, res) => { 950 const site = res.locals.site; 951 const back = `${res.locals.siteUrlBase || ''}/messages`; 952 const answer = req.body.answer === 'accept' ? 'Accept' : (req.body.answer === 'reject' ? 'Reject' : null); 953 const guardian = String(req.body.guardian || '').trim(); 954 if (!site || !answer || !guardian) return res.redirect(back + '?error=guardianship'); 955 const row = Guardianship.getRelation(site.slug, 'ward', guardian); 956 if (!row || row.status !== 'offered') return res.redirect(back + '?error=guardianship'); 957 try { 958 const base = (process.env.PUBLIC_BASE_URL || '').replace(/\/+$/, ''); 959 const me = ActivityPubService.actorId(base, site.slug); 960 const r = await Guardianship.handleGuardianshipOutbox(site, { 961 type: answer, 962 object: row.offer_id || { type: 'Relationship', subject: me, relationship: 'shaer:Guardian', object: guardian }, 963 }); 964 if (r && r.status < 400) return res.redirect(back + '?success=' + (answer === 'Accept' ? 'guardian_accepted' : 'guardian_rejected')); 965 } catch { /* fall through */ } 966 res.redirect(back + '?error=guardianship'); 937 967 }); 938 968 router.get('/fediverse', requireSiteManager, (req, res) => res.redirect(`${res.locals.siteUrlBase || ''}/messages`));
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)