]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix well known and json parser with mastodon
authorChocobozzz <florian.bigard@gmail.com>
Wed, 29 Nov 2017 10:34:44 +0000 (11:34 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Wed, 29 Nov 2017 10:34:44 +0000 (11:34 +0100)
server.ts
server/controllers/webfinger.ts
server/initializers/constants.ts
server/initializers/database.ts
server/middlewares/activitypub.ts
server/models/video/video.ts
yarn.lock

index 84535c7a5ab5e53bfacc23fb7b82e2ce90a93779..0e963c3d30b501f77a84a122975d836ddaff55e3 100644 (file)
--- 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 -----------
index 1cea513a181e356d146b226c84180293480345dd..78e5dee79747a31c21592d4ceae71f021ace3ed5 100644 (file)
@@ -27,6 +27,7 @@ function webfingerController (req: express.Request, res: express.Response, next:
     links: [
       {
         rel: 'self',
+        type: 'application/activity+json',
         href: account.url
       }
     ]
index 82373ba84379790d87ef464f495f06d33b01f7a9..6d8aa73328c9fed4ee301c6798ca657bd493e31a 100644 (file)
@@ -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]
 
 // ---------------------------------------------------------------------------
 
index 9b9a81e269a8364ea4667794ff6f5ac9e735cf8d..90dbba5b9f87cd89c5a1012b63731def6b5986b8 100644 (file)
@@ -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 = message
     if (isTestInstance() === true && benchmark !== undefined) {
       newMessage += ' | ' + benchmark + 'ms'
index 061b2dddc432d4ec156f47b04be688832e29a3a8..34386e76d90c3b5fd0ee1021f43ed9454b34ed23 100644 (file)
@@ -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)
index 3f416d04cc6655438133592ebbb1e69259b0c544..f3469c1dea3bad5847360826a015fd23f7e514f5 100644 (file)
@@ -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,
index 497f5da1f40886c9e93ffd7d48cd1e09b84ac9a0..4e92fd33637837c9a52ea30f7325b434db0a31f1 100644 (file)
--- 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"