diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-28 11:16:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-28 11:16:08 +0100 |
commit | da854ddd502cd70685ef779c673b9e63757b8aa0 (patch) | |
tree | 21501d170cceaa044a5f23449cbd2eb47fd6415d /server/controllers/activitypub | |
parent | f40bbe3146553ef45515ee6b6d93ce6028f045ca (diff) | |
download | PeerTube-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.ts | 27 | ||||
-rw-r--r-- | server/controllers/activitypub/inbox.ts | 2 |
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 |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { activityPubCollectionPagination, pageToStartAndCount } from '../../helpers' | 3 | import { activityPubCollectionPagination } from '../../helpers/activitypub' |
4 | import { pageToStartAndCount } from '../../helpers/core-utils' | ||
4 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' | 5 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' |
5 | import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' | 6 | import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' |
6 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' | 7 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' |
7 | import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' | 8 | import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' |
9 | import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' | ||
8 | import { AccountModel } from '../../models/account/account' | 10 | import { AccountModel } from '../../models/account/account' |
9 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 11 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
10 | import { VideoModel } from '../../models/video/video' | 12 | import { VideoModel } from '../../models/video/video' |
11 | import { VideoChannelModel } from '../../models/video/video-channel' | 13 | import { VideoChannelModel } from '../../models/video/video-channel' |
14 | import { VideoCommentModel } from '../../models/video/video-comment' | ||
12 | import { VideoShareModel } from '../../models/video/video-share' | 15 | import { VideoShareModel } from '../../models/video/video-share' |
13 | 16 | ||
14 | const activityPubClientRouter = express.Router() | 17 | const activityPubClientRouter = express.Router() |
@@ -30,7 +33,7 @@ activityPubClientRouter.get('/account/:name/following', | |||
30 | 33 | ||
31 | activityPubClientRouter.get('/videos/watch/:id', | 34 | activityPubClientRouter.get('/videos/watch/:id', |
32 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | 35 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), |
33 | executeIfActivityPub(videoController) | 36 | executeIfActivityPub(asyncMiddleware(videoController)) |
34 | ) | 37 | ) |
35 | 38 | ||
36 | activityPubClientRouter.get('/videos/watch/:id/announces/:accountId', | 39 | activityPubClientRouter.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 | ||
44 | activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', | ||
45 | executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)), | ||
46 | executeIfActivityPub(asyncMiddleware(videoCommentController)) | ||
47 | ) | ||
48 | |||
41 | activityPubClientRouter.get('/video-channels/:id', | 49 | activityPubClientRouter.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 { | |||
54 | function accountController (req: express.Request, res: express.Response, next: express.NextFunction) { | 62 | function 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 | ||
60 | async function accountFollowersController (req: express.Request, res: express.Response, next: express.NextFunction) { | 69 | async 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 | ||
84 | function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { | 93 | async 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 | ||
90 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { | 101 | async 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 | |||
114 | async 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' | 2 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' |
3 | import { logger } from '../../helpers' | ||
4 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' | 3 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' |
4 | import { logger } from '../../helpers/logger' | ||
5 | import { processActivities } from '../../lib/activitypub/process/process' | 5 | import { processActivities } from '../../lib/activitypub/process/process' |
6 | import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares' | 6 | import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares' |
7 | import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' | 7 | import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' |