aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts3
-rw-r--r--server/middlewares/activitypub.ts5
2 files changed, 6 insertions, 2 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 4f63cbb02..e3d779456 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -316,6 +316,8 @@ const CACHE = {
316 } 316 }
317} 317}
318 318
319const ACCEPT_HEADERS = ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.concat('html', 'application/json')
320
319// --------------------------------------------------------------------------- 321// ---------------------------------------------------------------------------
320 322
321const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->' 323const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->'
@@ -336,6 +338,7 @@ if (isTestInstance() === true) {
336 338
337export { 339export {
338 API_VERSION, 340 API_VERSION,
341 ACCEPT_HEADERS,
339 BCRYPT_SALT_SIZE, 342 BCRYPT_SALT_SIZE,
340 CACHE, 343 CACHE,
341 CONFIG, 344 CONFIG,
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 485645720..c2ad18195 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -3,7 +3,7 @@ import { NextFunction, Request, RequestHandler, Response } from 'express'
3import { ActivityPubSignature } from '../../shared' 3import { ActivityPubSignature } from '../../shared'
4import { isSignatureVerified, logger } from '../helpers' 4import { isSignatureVerified, logger } from '../helpers'
5import { database as db } from '../initializers' 5import { database as db } from '../initializers'
6import { ACTIVITY_PUB } from '../initializers/constants' 6import { ACCEPT_HEADERS, ACTIVITY_PUB } from '../initializers/constants'
7import { fetchRemoteAccount, saveAccountAndServerIfNotExist } from '../lib/activitypub/account' 7import { fetchRemoteAccount, saveAccountAndServerIfNotExist } from '../lib/activitypub/account'
8 8
9async function checkSignature (req: Request, res: Response, next: NextFunction) { 9async function checkSignature (req: Request, res: Response, next: NextFunction) {
@@ -37,7 +37,8 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
37 37
38function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { 38function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
39 return (req: Request, res: Response, next: NextFunction) => { 39 return (req: Request, res: Response, next: NextFunction) => {
40 if (!req.accepts(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS)) { 40 const accepted = req.accepts(ACCEPT_HEADERS)
41 if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) {
41 return next() 42 return next()
42 } 43 }
43 44