Fix activitypub check headers

pull/143/head
Chocobozzz 2017-11-30 13:15:25 +01:00
parent 6cbdbdef17
commit 1b5b10d131
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 20 additions and 6 deletions

View File

@ -220,11 +220,11 @@ const VIDEO_MIMETYPE_EXT = {
const SERVER_ACCOUNT_NAME = 'peertube'
const ACTIVITY_PUB = {
ACCEPT_HEADERS: [
'application/activity+json, application/ld+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
POTENTIAL_ACCEPT_HEADERS: [
'application/activity+json',
'application/ld+json'
],
ACCEPT_HEADER: '',
ACCEPT_HEADER: 'application/activity+json, application/ld+json',
PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
COLLECTION_ITEMS_PER_PAGE: 10,
FETCH_PAGE_LIMIT: 100,
@ -235,7 +235,6 @@ const ACTIVITY_PUB = {
MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
}
}
ACTIVITY_PUB.ACCEPT_HEADER = ACTIVITY_PUB.ACCEPT_HEADERS[0]
// ---------------------------------------------------------------------------

View File

@ -37,7 +37,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
return (req: Request, res: Response, next: NextFunction) => {
if (req.accepts(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS) === false) {
if (!req.accepts(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS)) {
return next()
}

View File

@ -0,0 +1,15 @@
import * as request from 'supertest'
function makeActivityPubGetRequest (url: string, path: string) {
return request(url)
.get(path)
.set('Accept', 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8')
.expect(200)
.expect('Content-Type', /json/)
}
// ---------------------------------------------------------------------------
export {
makeActivityPubGetRequest
}