]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Activity Pub improvements
authorChocobozzz <me@florianbigard.com>
Thu, 11 Jan 2018 18:17:43 +0000 (19:17 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 11 Jan 2018 18:17:43 +0000 (19:17 +0100)
server/initializers/constants.ts
server/lib/activitypub/process/process-update.ts
server/lib/activitypub/send/misc.ts
server/middlewares/activitypub.ts

index a3c128d1fe744bd79917cccf20933d10497b95ce..eda3403f25592aa31747a5924b1a3a3d5297fed9 100644 (file)
@@ -270,7 +270,8 @@ const SERVER_ACTOR_NAME = 'peertube'
 const ACTIVITY_PUB = {
   POTENTIAL_ACCEPT_HEADERS: [
     'application/activity+json',
-    'application/ld+json'
+    'application/ld+json',
+    'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
   ],
   ACCEPT_HEADER: 'application/activity+json, application/ld+json',
   PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
index a5431c76b93f7904c9932337a14ffa2933db47e1..5439a47f2ca092af1878dbbbd9c84ff5737ae339 100644 (file)
@@ -66,17 +66,19 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
 
       const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to, activity.cc)
       videoInstance.set('name', videoData.name)
+      videoInstance.set('uuid', videoData.uuid)
+      videoInstance.set('url', videoData.url)
       videoInstance.set('category', videoData.category)
       videoInstance.set('licence', videoData.licence)
       videoInstance.set('language', videoData.language)
+      videoInstance.set('description', videoData.description)
       videoInstance.set('nsfw', videoData.nsfw)
       videoInstance.set('commentsEnabled', videoData.commentsEnabled)
-      videoInstance.set('privacy', videoData.privacy)
-      videoInstance.set('description', videoData.description)
       videoInstance.set('duration', videoData.duration)
       videoInstance.set('createdAt', videoData.createdAt)
       videoInstance.set('updatedAt', videoData.updatedAt)
       videoInstance.set('views', videoData.views)
+      videoInstance.set('privacy', videoData.privacy)
 
       await videoInstance.save(sequelizeOptions)
 
index 2a9f4cae868ac0bf0b8c8181d52433a326b9ad72..261586ae43b3bdbd26aaf7ca1d8b8cff4b07916d 100644 (file)
@@ -166,14 +166,14 @@ async function computeFollowerUris (toActorFollower: ActorModel[], actorsExcepti
   const toActorFollowerIds = toActorFollower.map(a => a.id)
 
   const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t)
-  const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl)
+  const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl || f.inboxUrl)
   return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
 }
 
 async function computeUris (toActors: ActorModel[], actorsException: ActorModel[] = []) {
-  const toActorSharedInboxesSet = new Set(toActors.map(a => a.sharedInboxUrl))
+  const toActorSharedInboxesSet = new Set(toActors.map(a => a.sharedInboxUrl || a.inboxUrl))
 
-  const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl)
+  const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl || f.inboxUrl)
   return Array.from(toActorSharedInboxesSet)
     .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
 }
index 1488b42ab1164bd701db841182da7d92c7eb0613..c7102b6bf7782733330c1c7e29aada3b85bfb5ce 100644 (file)
@@ -35,6 +35,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
 function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
   return (req: Request, res: Response, next: NextFunction) => {
     const accepted = req.accepts(ACCEPT_HEADERS)
+    console.log(accepted)
     if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) {
       return next()
     }