aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-30 13:37:11 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-30 13:37:11 +0100
commit4f49137101a665f6a76bd8159a175a2aa680af96 (patch)
tree97f4956a2ae4642fefbd67f2839f4ab525e00821 /server/middlewares
parent6cae49d26299b22ed879156ba5b8fb68a34e3713 (diff)
downloadPeerTube-4f49137101a665f6a76bd8159a175a2aa680af96.tar.gz
PeerTube-4f49137101a665f6a76bd8159a175a2aa680af96.tar.zst
PeerTube-4f49137101a665f6a76bd8159a175a2aa680af96.zip
Fix req accepts
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/activitypub.ts5
1 files changed, 3 insertions, 2 deletions
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