ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix well known and json parser with mastodon
Chocobozzz165cdc75bf19
diff --git a/server.ts b/server.tsindex 84535c7a5a..0e963c3d30 100644--- a/server.ts+++ b/server.ts@@ -76,7 +76,10 @@ app.use(morgan('combined', {stream: { write: logger.info }}))// For body requests-app.use(bodyParser.json({ limit: '500kb' }))+app.use(bodyParser.json({+ type: 'application/*+json',+ limit: '500kb'+}))app.use(bodyParser.urlencoded({ extended: false }))// ----------- Tracker -----------diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.tsindex 1cea513a18..78e5dee797 100644--- a/server/controllers/webfinger.ts+++ b/server/controllers/webfinger.ts@@ -27,6 +27,7 @@ function webfingerController (req: express.Request, res: express.Response, next:links: [{rel: 'self',+ type: 'application/activity+json',href: account.url}]diff --git a/server/initializers/constants.ts b/server/initializers/constants.tsindex 82373ba843..6d8aa73328 100644--- a/server/initializers/constants.ts+++ b/server/initializers/constants.ts@@ -219,7 +219,11 @@ const VIDEO_MIMETYPE_EXT = {const SERVER_ACCOUNT_NAME = 'peertube'const ACTIVITY_PUB = {- ACCEPT_HEADER: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',+ ACCEPT_HEADERS: [+ 'application/activity+json, application/ld+json',+ 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'+ ],+ ACCEPT_HEADER: '',PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',COLLECTION_ITEMS_PER_PAGE: 10,FETCH_PAGE_LIMIT: 100,@@ -230,6 +234,7 @@ const ACTIVITY_PUB = {MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]}}+ACTIVITY_PUB.ACCEPT_HEADER = ACTIVITY_PUB.ACCEPT_HEADERS[0]// ---------------------------------------------------------------------------diff --git a/server/initializers/database.ts b/server/initializers/database.tsindex 9b9a81e269..90dbba5b9f 100644--- a/server/initializers/database.ts+++ b/server/initializers/database.ts@@ -66,6 +66,8 @@ const sequelize = new Sequelize(dbname, username, password, {operatorsAliases: false,logging: (message: string, benchmark: number) => {+ if (process.env.NODE_DB_LOG === 'false') return+let newMessage = messageif (isTestInstance() === true && benchmark !== undefined) {newMessage += ' | ' + benchmark + 'ms'diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.tsindex 061b2dddc4..34386e76d9 100644--- a/server/middlewares/activitypub.ts+++ b/server/middlewares/activitypub.ts@@ -37,10 +37,12 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {return (req: Request, res: Response, next: NextFunction) => {- if (req.header('Accept') !== ACTIVITY_PUB.ACCEPT_HEADER) {+ if (ACTIVITY_PUB.ACCEPT_HEADERS.indexOf(req.header('Accept')) === -1) {return next()}+ logger.debug('ActivityPub request for %s.', req.url)+if (Array.isArray(fun) === true) {return eachSeries(fun as RequestHandler[], (f, cb) => {f(req, res, cb)diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex 3f416d04cc..f3469c1dea 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -616,6 +616,13 @@ toActivityPubObject = function (this: VideoInstance) {})}+ // Add video url too+ url.push({+ type: 'Link',+ mimeType: 'text/html',+ url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid+ })+const videoObject: VideoTorrentObject = {type: 'Video' as 'Video',id: this.url,diff --git a/yarn.lock b/yarn.lockindex 497f5da1f4..4e92fd3363 100644--- a/yarn.lock+++ b/yarn.lock@@ -471,9 +471,9 @@ bitcore-lib@^0.13.7:inherits "=2.0.1"lodash "=3.10.1"-"bitcore-message@github:comakery/bitcore-message#dist":+"bitcore-message@github:CoMakery/bitcore-message#dist":version "1.0.2"- resolved "https://codeload.github.com/comakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf"+ resolved "https://codeload.github.com/CoMakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf"dependencies:bitcore-lib "^0.13.7"