aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-11 19:17:43 +0100
committerChocobozzz <me@florianbigard.com>2018-01-11 19:17:43 +0100
commit9a8cbd8278a37ee414f17d7de7c7281123484ba1 (patch)
tree11dcf06211e6e49cfb638172c3fa65011ff7fb88 /server
parent05bc4dfa069be5273765a68652598d72dbf482fb (diff)
downloadPeerTube-9a8cbd8278a37ee414f17d7de7c7281123484ba1.tar.gz
PeerTube-9a8cbd8278a37ee414f17d7de7c7281123484ba1.tar.zst
PeerTube-9a8cbd8278a37ee414f17d7de7c7281123484ba1.zip
Activity Pub improvements
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts3
-rw-r--r--server/lib/activitypub/process/process-update.ts6
-rw-r--r--server/lib/activitypub/send/misc.ts6
-rw-r--r--server/middlewares/activitypub.ts1
4 files changed, 10 insertions, 6 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index a3c128d1f..eda3403f2 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -270,7 +270,8 @@ const SERVER_ACTOR_NAME = 'peertube'
270const ACTIVITY_PUB = { 270const ACTIVITY_PUB = {
271 POTENTIAL_ACCEPT_HEADERS: [ 271 POTENTIAL_ACCEPT_HEADERS: [
272 'application/activity+json', 272 'application/activity+json',
273 'application/ld+json' 273 'application/ld+json',
274 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
274 ], 275 ],
275 ACCEPT_HEADER: 'application/activity+json, application/ld+json', 276 ACCEPT_HEADER: 'application/activity+json, application/ld+json',
276 PUBLIC: 'https://www.w3.org/ns/activitystreams#Public', 277 PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index a5431c76b..5439a47f2 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -66,17 +66,19 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
66 66
67 const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to, activity.cc) 67 const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to, activity.cc)
68 videoInstance.set('name', videoData.name) 68 videoInstance.set('name', videoData.name)
69 videoInstance.set('uuid', videoData.uuid)
70 videoInstance.set('url', videoData.url)
69 videoInstance.set('category', videoData.category) 71 videoInstance.set('category', videoData.category)
70 videoInstance.set('licence', videoData.licence) 72 videoInstance.set('licence', videoData.licence)
71 videoInstance.set('language', videoData.language) 73 videoInstance.set('language', videoData.language)
74 videoInstance.set('description', videoData.description)
72 videoInstance.set('nsfw', videoData.nsfw) 75 videoInstance.set('nsfw', videoData.nsfw)
73 videoInstance.set('commentsEnabled', videoData.commentsEnabled) 76 videoInstance.set('commentsEnabled', videoData.commentsEnabled)
74 videoInstance.set('privacy', videoData.privacy)
75 videoInstance.set('description', videoData.description)
76 videoInstance.set('duration', videoData.duration) 77 videoInstance.set('duration', videoData.duration)
77 videoInstance.set('createdAt', videoData.createdAt) 78 videoInstance.set('createdAt', videoData.createdAt)
78 videoInstance.set('updatedAt', videoData.updatedAt) 79 videoInstance.set('updatedAt', videoData.updatedAt)
79 videoInstance.set('views', videoData.views) 80 videoInstance.set('views', videoData.views)
81 videoInstance.set('privacy', videoData.privacy)
80 82
81 await videoInstance.save(sequelizeOptions) 83 await videoInstance.save(sequelizeOptions)
82 84
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts
index 2a9f4cae8..261586ae4 100644
--- a/server/lib/activitypub/send/misc.ts
+++ b/server/lib/activitypub/send/misc.ts
@@ -166,14 +166,14 @@ async function computeFollowerUris (toActorFollower: ActorModel[], actorsExcepti
166 const toActorFollowerIds = toActorFollower.map(a => a.id) 166 const toActorFollowerIds = toActorFollower.map(a => a.id)
167 167
168 const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t) 168 const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t)
169 const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl) 169 const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl || f.inboxUrl)
170 return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) 170 return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
171} 171}
172 172
173async function computeUris (toActors: ActorModel[], actorsException: ActorModel[] = []) { 173async function computeUris (toActors: ActorModel[], actorsException: ActorModel[] = []) {
174 const toActorSharedInboxesSet = new Set(toActors.map(a => a.sharedInboxUrl)) 174 const toActorSharedInboxesSet = new Set(toActors.map(a => a.sharedInboxUrl || a.inboxUrl))
175 175
176 const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl) 176 const sharedInboxesException = actorsException.map(f => f.sharedInboxUrl || f.inboxUrl)
177 return Array.from(toActorSharedInboxesSet) 177 return Array.from(toActorSharedInboxesSet)
178 .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) 178 .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
179} 179}
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 1488b42ab..c7102b6bf 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -35,6 +35,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
35function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { 35function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
36 return (req: Request, res: Response, next: NextFunction) => { 36 return (req: Request, res: Response, next: NextFunction) => {
37 const accepted = req.accepts(ACCEPT_HEADERS) 37 const accepted = req.accepts(ACCEPT_HEADERS)
38 console.log(accepted)
38 if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) { 39 if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) {
39 return next() 40 return next()
40 } 41 }