Changeset dd568e7 in Klonkt for src/routes/activitypub.js
- Timestamp:
- 07/19/2026 03:15:18 AM (7 weeks ago)
- Branches:
- main
- Children:
- bf72108
- Parents:
- d49b60b
- git-author:
- Robin <roboburr@…> (07/19/2026 03:14:01 AM)
- git-committer:
- Robin <roboburr@…> (07/19/2026 03:15:18 AM)
- File:
-
- 1 edited
-
src/routes/activitypub.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/activitypub.js
rd49b60b rdd568e7 18 18 import { apReadLimiter, apInboxLimiter } from '../middleware/rate-limit.js'; 19 19 import { apEnabled } from '../services/SettingsService.js'; 20 import OAuth from '../services/OAuthService.js'; 20 21 21 22 const router = express.Router(); … … 193 194 }); 194 195 196 // ── Outbox POST: ActivityPub Client-to-Server ───────────────────── 197 // A bearer-authenticated client (Shaer) POSTs an activity; we translate it onto 198 // the normal delivery machinery. The token is scoped to one user+site (OAuth 199 // consent), so it must match the slug in the URL. (Declared after apJson, which 200 // this shares with the inbox handler.) 201 router.post('/ap/users/:slug/outbox', apInboxLimiter, apJson, async (req, res) => { 202 const auth = OAuth.verifyBearer(req.headers.authorization); 203 if (!auth) { res.set('WWW-Authenticate', 'Bearer'); return res.status(401).json({ error: 'invalid_token' }); } 204 if (auth.site.slug !== req.params.slug) return res.status(403).json({ error: 'wrong_site', detail: 'token is scoped to a different site' }); 205 if (auth.user.readonly) return res.status(403).json({ error: 'read_only_account' }); 206 207 const out = await AP.ingestOutboxActivity(auth.site, auth.user, req.body); 208 if (out.error) return res.status(out.status || 400).json({ error: out.error, detail: out.detail }); 209 // 201 Created → Location header (AP spec); 202 Accepted for side-effect verbs. 210 if (out.status === 201 && out.url) res.set('Location', out.url); 211 return res.status(out.status || 202).json({ ok: true, id: out.id, url: out.url }); 212 }); 213 195 214 export default router;
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)