aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 11:16:08 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 11:16:08 +0100
commitda854ddd502cd70685ef779c673b9e63757b8aa0 (patch)
tree21501d170cceaa044a5f23449cbd2eb47fd6415d /server/controllers/activitypub
parentf40bbe3146553ef45515ee6b6d93ce6028f045ca (diff)
downloadPeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.gz
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.zst
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.zip
Propagate old comment on new follow
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r--server/controllers/activitypub/client.ts27
-rw-r--r--server/controllers/activitypub/inbox.ts2
2 files changed, 23 insertions, 6 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 8c6294ff7..71e706346 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -1,14 +1,17 @@
1// Intercept ActivityPub client requests 1// Intercept ActivityPub client requests
2import * as express from 'express' 2import * as express from 'express'
3import { activityPubCollectionPagination, pageToStartAndCount } from '../../helpers' 3import { activityPubCollectionPagination } from '../../helpers/activitypub'
4import { pageToStartAndCount } from '../../helpers/core-utils'
4import { ACTIVITY_PUB, CONFIG } from '../../initializers' 5import { ACTIVITY_PUB, CONFIG } from '../../initializers'
5import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' 6import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send'
6import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' 7import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares'
7import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' 8import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators'
9import { videoCommentGetValidator } from '../../middlewares/validators/video-comments'
8import { AccountModel } from '../../models/account/account' 10import { AccountModel } from '../../models/account/account'
9import { ActorFollowModel } from '../../models/activitypub/actor-follow' 11import { ActorFollowModel } from '../../models/activitypub/actor-follow'
10import { VideoModel } from '../../models/video/video' 12import { VideoModel } from '../../models/video/video'
11import { VideoChannelModel } from '../../models/video/video-channel' 13import { VideoChannelModel } from '../../models/video/video-channel'
14import { VideoCommentModel } from '../../models/video/video-comment'
12import { VideoShareModel } from '../../models/video/video-share' 15import { VideoShareModel } from '../../models/video/video-share'
13 16
14const activityPubClientRouter = express.Router() 17const activityPubClientRouter = express.Router()
@@ -30,7 +33,7 @@ activityPubClientRouter.get('/account/:name/following',
30 33
31activityPubClientRouter.get('/videos/watch/:id', 34activityPubClientRouter.get('/videos/watch/:id',
32 executeIfActivityPub(asyncMiddleware(videosGetValidator)), 35 executeIfActivityPub(asyncMiddleware(videosGetValidator)),
33 executeIfActivityPub(videoController) 36 executeIfActivityPub(asyncMiddleware(videoController))
34) 37)
35 38
36activityPubClientRouter.get('/videos/watch/:id/announces/:accountId', 39activityPubClientRouter.get('/videos/watch/:id/announces/:accountId',
@@ -38,6 +41,11 @@ activityPubClientRouter.get('/videos/watch/:id/announces/:accountId',
38 executeIfActivityPub(asyncMiddleware(videoAnnounceController)) 41 executeIfActivityPub(asyncMiddleware(videoAnnounceController))
39) 42)
40 43
44activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId',
45 executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)),
46 executeIfActivityPub(asyncMiddleware(videoCommentController))
47)
48
41activityPubClientRouter.get('/video-channels/:id', 49activityPubClientRouter.get('/video-channels/:id',
42 executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)), 50 executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)),
43 executeIfActivityPub(asyncMiddleware(videoChannelController)) 51 executeIfActivityPub(asyncMiddleware(videoChannelController))
@@ -54,7 +62,8 @@ export {
54function accountController (req: express.Request, res: express.Response, next: express.NextFunction) { 62function accountController (req: express.Request, res: express.Response, next: express.NextFunction) {
55 const account: AccountModel = res.locals.account 63 const account: AccountModel = res.locals.account
56 64
57 return res.json(account.toActivityPubObject()).end() 65 return res.json(account.toActivityPubObject())
66 .end()
58} 67}
59 68
60async function accountFollowersController (req: express.Request, res: express.Response, next: express.NextFunction) { 69async function accountFollowersController (req: express.Request, res: express.Response, next: express.NextFunction) {
@@ -81,10 +90,12 @@ async function accountFollowingController (req: express.Request, res: express.Re
81 return res.json(activityPubResult) 90 return res.json(activityPubResult)
82} 91}
83 92
84function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { 93async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) {
85 const video: VideoModel = res.locals.video 94 const video: VideoModel = res.locals.video
86 95
87 return res.json(video.toActivityPubObject()) 96 // We need more attributes
97 const videoAll = await VideoModel.loadAndPopulateAll(video.id)
98 return res.json(videoAll.toActivityPubObject())
88} 99}
89 100
90async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { 101async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) {
@@ -99,3 +110,9 @@ async function videoChannelController (req: express.Request, res: express.Respon
99 110
100 return res.json(videoChannel.toActivityPubObject()) 111 return res.json(videoChannel.toActivityPubObject())
101} 112}
113
114async function videoCommentController (req: express.Request, res: express.Response, next: express.NextFunction) {
115 const videoComment: VideoCommentModel = res.locals.videoComment
116
117 return res.json(videoComment.toActivityPubObject())
118}
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index 8332eabb1..bfcb7b369 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' 2import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
3import { logger } from '../../helpers'
4import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' 3import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
4import { logger } from '../../helpers/logger'
5import { processActivities } from '../../lib/activitypub/process/process' 5import { processActivities } from '../../lib/activitypub/process/process'
6import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares' 6import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares'
7import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' 7import { activityPubValidator } from '../../middlewares/validators/activitypub/activity'