diff options
-rw-r--r-- | server.ts | 5 | ||||
-rw-r--r-- | server/controllers/webfinger.ts | 1 | ||||
-rw-r--r-- | server/initializers/constants.ts | 7 | ||||
-rw-r--r-- | server/initializers/database.ts | 2 | ||||
-rw-r--r-- | server/middlewares/activitypub.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 7 | ||||
-rw-r--r-- | yarn.lock | 4 |
7 files changed, 25 insertions, 5 deletions
@@ -76,7 +76,10 @@ app.use(morgan('combined', { | |||
76 | stream: { write: logger.info } | 76 | stream: { write: logger.info } |
77 | })) | 77 | })) |
78 | // For body requests | 78 | // For body requests |
79 | app.use(bodyParser.json({ limit: '500kb' })) | 79 | app.use(bodyParser.json({ |
80 | type: 'application/*+json', | ||
81 | limit: '500kb' | ||
82 | })) | ||
80 | app.use(bodyParser.urlencoded({ extended: false })) | 83 | app.use(bodyParser.urlencoded({ extended: false })) |
81 | 84 | ||
82 | // ----------- Tracker ----------- | 85 | // ----------- Tracker ----------- |
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts index 1cea513a1..78e5dee79 100644 --- a/server/controllers/webfinger.ts +++ b/server/controllers/webfinger.ts | |||
@@ -27,6 +27,7 @@ function webfingerController (req: express.Request, res: express.Response, next: | |||
27 | links: [ | 27 | links: [ |
28 | { | 28 | { |
29 | rel: 'self', | 29 | rel: 'self', |
30 | type: 'application/activity+json', | ||
30 | href: account.url | 31 | href: account.url |
31 | } | 32 | } |
32 | ] | 33 | ] |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 82373ba84..6d8aa7332 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -219,7 +219,11 @@ const VIDEO_MIMETYPE_EXT = { | |||
219 | const SERVER_ACCOUNT_NAME = 'peertube' | 219 | const SERVER_ACCOUNT_NAME = 'peertube' |
220 | 220 | ||
221 | const ACTIVITY_PUB = { | 221 | const ACTIVITY_PUB = { |
222 | ACCEPT_HEADER: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', | 222 | ACCEPT_HEADERS: [ |
223 | 'application/activity+json, application/ld+json', | ||
224 | 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' | ||
225 | ], | ||
226 | ACCEPT_HEADER: '', | ||
223 | PUBLIC: 'https://www.w3.org/ns/activitystreams#Public', | 227 | PUBLIC: 'https://www.w3.org/ns/activitystreams#Public', |
224 | COLLECTION_ITEMS_PER_PAGE: 10, | 228 | COLLECTION_ITEMS_PER_PAGE: 10, |
225 | FETCH_PAGE_LIMIT: 100, | 229 | FETCH_PAGE_LIMIT: 100, |
@@ -230,6 +234,7 @@ const ACTIVITY_PUB = { | |||
230 | MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ] | 234 | MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ] |
231 | } | 235 | } |
232 | } | 236 | } |
237 | ACTIVITY_PUB.ACCEPT_HEADER = ACTIVITY_PUB.ACCEPT_HEADERS[0] | ||
233 | 238 | ||
234 | // --------------------------------------------------------------------------- | 239 | // --------------------------------------------------------------------------- |
235 | 240 | ||
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 9b9a81e26..90dbba5b9 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -66,6 +66,8 @@ const sequelize = new Sequelize(dbname, username, password, { | |||
66 | operatorsAliases: false, | 66 | operatorsAliases: false, |
67 | 67 | ||
68 | logging: (message: string, benchmark: number) => { | 68 | logging: (message: string, benchmark: number) => { |
69 | if (process.env.NODE_DB_LOG === 'false') return | ||
70 | |||
69 | let newMessage = message | 71 | let newMessage = message |
70 | if (isTestInstance() === true && benchmark !== undefined) { | 72 | if (isTestInstance() === true && benchmark !== undefined) { |
71 | newMessage += ' | ' + benchmark + 'ms' | 73 | newMessage += ' | ' + benchmark + 'ms' |
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 061b2dddc..34386e76d 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts | |||
@@ -37,10 +37,12 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) | |||
37 | 37 | ||
38 | function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { | 38 | function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { |
39 | return (req: Request, res: Response, next: NextFunction) => { | 39 | return (req: Request, res: Response, next: NextFunction) => { |
40 | if (req.header('Accept') !== ACTIVITY_PUB.ACCEPT_HEADER) { | 40 | if (ACTIVITY_PUB.ACCEPT_HEADERS.indexOf(req.header('Accept')) === -1) { |
41 | return next() | 41 | return next() |
42 | } | 42 | } |
43 | 43 | ||
44 | logger.debug('ActivityPub request for %s.', req.url) | ||
45 | |||
44 | if (Array.isArray(fun) === true) { | 46 | if (Array.isArray(fun) === true) { |
45 | return eachSeries(fun as RequestHandler[], (f, cb) => { | 47 | return eachSeries(fun as RequestHandler[], (f, cb) => { |
46 | f(req, res, cb) | 48 | f(req, res, cb) |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 3f416d04c..f3469c1de 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -616,6 +616,13 @@ toActivityPubObject = function (this: VideoInstance) { | |||
616 | }) | 616 | }) |
617 | } | 617 | } |
618 | 618 | ||
619 | // Add video url too | ||
620 | url.push({ | ||
621 | type: 'Link', | ||
622 | mimeType: 'text/html', | ||
623 | url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid | ||
624 | }) | ||
625 | |||
619 | const videoObject: VideoTorrentObject = { | 626 | const videoObject: VideoTorrentObject = { |
620 | type: 'Video' as 'Video', | 627 | type: 'Video' as 'Video', |
621 | id: this.url, | 628 | id: this.url, |
@@ -471,9 +471,9 @@ bitcore-lib@^0.13.7: | |||
471 | inherits "=2.0.1" | 471 | inherits "=2.0.1" |
472 | lodash "=3.10.1" | 472 | lodash "=3.10.1" |
473 | 473 | ||
474 | "bitcore-message@github:comakery/bitcore-message#dist": | 474 | "bitcore-message@github:CoMakery/bitcore-message#dist": |
475 | version "1.0.2" | 475 | version "1.0.2" |
476 | resolved "https://codeload.github.com/comakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf" | 476 | resolved "https://codeload.github.com/CoMakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf" |
477 | dependencies: | 477 | dependencies: |
478 | bitcore-lib "^0.13.7" | 478 | bitcore-lib "^0.13.7" |
479 | 479 | ||