diff options
author | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-02 12:14:38 +0000 |
---|---|---|
committer | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-02 12:14:38 +0000 |
commit | 7bd4eb728d27636321e9ac6dadd764ef5fa95af1 (patch) | |
tree | 4db3ca79cc85f3022918096cd5d443d4531f0759 /src/routes | |
parent | fbd2dd29739b76e76855a3d4c87d9d43da2953c2 (diff) |
refactor: send and accept only spec-compliant AP headers
Diffstat (limited to 'src/routes')
-rw-r--r-- | src/routes/frontend.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/routes/frontend.ts b/src/routes/frontend.ts index c405572..cc97ab8 100644 --- a/src/routes/frontend.ts +++ b/src/routes/frontend.ts @@ -6,6 +6,10 @@ import getConfig, { frontendConfig } from "../lib/config.js"; import { addToLog, exportICal } from "../helpers.js"; import Event from "../models/Event.js"; import EventGroup, { IEventGroup } from "../models/EventGroup.js"; +import { + acceptsActivityPub, + activityPubContentType, +} from "../lib/activitypub.js"; const config = getConfig(); @@ -174,13 +178,8 @@ router.get("/:eventID", async (req: Request, res: Response) => { : null, url: `https://${config.general.domain}/` + req.params.eventID, }; - if ( - req.headers.accept && - (req.headers.accept.includes("application/activity+json") || - req.headers.accept.includes("application/json") || - req.headers.accept.includes("application/json+ld")) - ) { - res.header("Content-Type", "application/activity+json").send( + if (acceptsActivityPub(req)) { + res.header("Content-Type", activityPubContentType).send( JSON.parse(event.activityPubActor || "{}"), ); } else { |