summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2019-10-04 10:29:28 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-10-04 10:29:28 +0900
commit75e2b075e1eda7b706050b633a5db943e8b800c7 (patch)
tree9cd7b67b1f5550548c563e08ed0cf627379e4569
parentFix: オフライン時に大室櫻子が出てこない (#5480) (diff)
downloadmisskey-75e2b075e1eda7b706050b633a5db943e8b800c7.tar.gz
misskey-75e2b075e1eda7b706050b633a5db943e8b800c7.tar.bz2
misskey-75e2b075e1eda7b706050b633a5db943e8b800c7.zip
Fix #5468 (#5470)
* Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * fix type error * trust the module * remove space * accept charset
-rw-r--r--src/server/activitypub.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts
index 6c8a2b915e..92e23380cb 100644
--- a/src/server/activitypub.ts
+++ b/src/server/activitypub.ts
@@ -40,18 +40,21 @@ function inbox(ctx: Router.RouterContext) {
ctx.status = 202;
}
+const ACTIVITY_JSON = 'application/activity+json; charset=utf-8';
+const LD_JSON = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"; charset=utf-8';
+
function isActivityPubReq(ctx: Router.RouterContext) {
ctx.response.vary('Accept');
- const accepted = ctx.accepts('html', 'application/activity+json', 'application/ld+json');
- return ['application/activity+json', 'application/ld+json'].includes(accepted as string);
+ const accepted = ctx.accepts('html', ACTIVITY_JSON, LD_JSON);
+ return typeof accepted === 'string' && !accepted.match(/html/);
}
export function setResponseType(ctx: Router.RouterContext) {
- const accept = ctx.accepts('application/activity+json', 'application/ld+json');
- if (accept === 'application/ld+json') {
- ctx.response.type = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"; charset=utf-8';
+ const accept = ctx.accepts(ACTIVITY_JSON, LD_JSON);
+ if (accept === LD_JSON) {
+ ctx.response.type = LD_JSON;
} else {
- ctx.response.type = 'application/activity+json; charset=utf-8';
+ ctx.response.type = ACTIVITY_JSON;
}
}