diff --git a/lib/activitypub/articles.ts b/lib/activitypub/articles.ts index 8d90d87..bb70ed7 100644 --- a/lib/activitypub/articles.ts +++ b/lib/activitypub/articles.ts @@ -59,9 +59,11 @@ export async function toFederate(db: Database): Promise<[string, Article][]> { export function route(router: Router) { router.use("/:category/:year/:slug/", (req, res, next) => { - if (req.accepts("text/html")) { + const best = req.accepts(["text/html", "application/activity+json"]); + console.log(best); + if (best === "text/html") { next(); - } else { + } else if (best === "application/activity+json") { const db = req.app.get("db") db.get("SELECT article_doc FROM articles WHERE id = $id", { $id: `/${req.params.category}/${req.params.year}/${req.params.slug}/` @@ -70,9 +72,11 @@ export function route(router: Router) { res.status(500).end(err); return; } - res.type("application/json"); + res.type("application/activity+json"); res.end(result.article_doc); }); + } else { + res.status(415).end("No acceptable content-type given. text/html or application/activity+json are supported"); } }); } \ No newline at end of file