aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts9
-rw-r--r--server/middlewares/activitypub.ts2
-rw-r--r--server/tests/utils/activitypub.ts15
3 files changed, 20 insertions, 6 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 8f278fb0b..4f63cbb02 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -220,11 +220,11 @@ const VIDEO_MIMETYPE_EXT = {
220const SERVER_ACCOUNT_NAME = 'peertube' 220const SERVER_ACCOUNT_NAME = 'peertube'
221 221
222const ACTIVITY_PUB = { 222const ACTIVITY_PUB = {
223 ACCEPT_HEADERS: [ 223 POTENTIAL_ACCEPT_HEADERS: [
224 'application/activity+json, application/ld+json', 224 'application/activity+json',
225 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' 225 'application/ld+json'
226 ], 226 ],
227 ACCEPT_HEADER: '', 227 ACCEPT_HEADER: 'application/activity+json, application/ld+json',
228 PUBLIC: 'https://www.w3.org/ns/activitystreams#Public', 228 PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
229 COLLECTION_ITEMS_PER_PAGE: 10, 229 COLLECTION_ITEMS_PER_PAGE: 10,
230 FETCH_PAGE_LIMIT: 100, 230 FETCH_PAGE_LIMIT: 100,
@@ -235,7 +235,6 @@ const ACTIVITY_PUB = {
235 MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ] 235 MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
236 } 236 }
237} 237}
238ACTIVITY_PUB.ACCEPT_HEADER = ACTIVITY_PUB.ACCEPT_HEADERS[0]
239 238
240// --------------------------------------------------------------------------- 239// ---------------------------------------------------------------------------
241 240
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 7db84de97..485645720 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -37,7 +37,7 @@ 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) === false) { 40 if (!req.accepts(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS)) {
41 return next() 41 return next()
42 } 42 }
43 43
diff --git a/server/tests/utils/activitypub.ts b/server/tests/utils/activitypub.ts
new file mode 100644
index 000000000..cf3c1c3b3
--- /dev/null
+++ b/server/tests/utils/activitypub.ts
@@ -0,0 +1,15 @@
1import * as request from 'supertest'
2
3function makeActivityPubGetRequest (url: string, path: string) {
4 return request(url)
5 .get(path)
6 .set('Accept', 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8')
7 .expect(200)
8 .expect('Content-Type', /json/)
9}
10
11// ---------------------------------------------------------------------------
12
13export {
14 makeActivityPubGetRequest
15}