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,
MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
}
}
-ACTIVITY_PUB.ACCEPT_HEADER = ACTIVITY_PUB.ACCEPT_HEADERS[0]
// ---------------------------------------------------------------------------
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()
}
--- /dev/null
+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
+}