From da854ddd502cd70685ef779c673b9e63757b8aa0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Dec 2017 11:16:08 +0100 Subject: Propagate old comment on new follow --- server/controllers/activitypub/client.ts | 27 ++++++++++++++++++++++----- server/controllers/activitypub/inbox.ts | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'server/controllers/activitypub') 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 @@ // Intercept ActivityPub client requests import * as express from 'express' -import { activityPubCollectionPagination, pageToStartAndCount } from '../../helpers' +import { activityPubCollectionPagination } from '../../helpers/activitypub' +import { pageToStartAndCount } from '../../helpers/core-utils' import { ACTIVITY_PUB, CONFIG } from '../../initializers' import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' +import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' import { AccountModel } from '../../models/account/account' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { VideoModel } from '../../models/video/video' import { VideoChannelModel } from '../../models/video/video-channel' +import { VideoCommentModel } from '../../models/video/video-comment' import { VideoShareModel } from '../../models/video/video-share' const activityPubClientRouter = express.Router() @@ -30,7 +33,7 @@ activityPubClientRouter.get('/account/:name/following', activityPubClientRouter.get('/videos/watch/:id', executeIfActivityPub(asyncMiddleware(videosGetValidator)), - executeIfActivityPub(videoController) + executeIfActivityPub(asyncMiddleware(videoController)) ) activityPubClientRouter.get('/videos/watch/:id/announces/:accountId', @@ -38,6 +41,11 @@ activityPubClientRouter.get('/videos/watch/:id/announces/:accountId', executeIfActivityPub(asyncMiddleware(videoAnnounceController)) ) +activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', + executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)), + executeIfActivityPub(asyncMiddleware(videoCommentController)) +) + activityPubClientRouter.get('/video-channels/:id', executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)), executeIfActivityPub(asyncMiddleware(videoChannelController)) @@ -54,7 +62,8 @@ export { function accountController (req: express.Request, res: express.Response, next: express.NextFunction) { const account: AccountModel = res.locals.account - return res.json(account.toActivityPubObject()).end() + return res.json(account.toActivityPubObject()) + .end() } 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 return res.json(activityPubResult) } -function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { +async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { const video: VideoModel = res.locals.video - return res.json(video.toActivityPubObject()) + // We need more attributes + const videoAll = await VideoModel.loadAndPopulateAll(video.id) + return res.json(videoAll.toActivityPubObject()) } 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 return res.json(videoChannel.toActivityPubObject()) } + +async function videoCommentController (req: express.Request, res: express.Response, next: express.NextFunction) { + const videoComment: VideoCommentModel = res.locals.videoComment + + return res.json(videoComment.toActivityPubObject()) +} 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 @@ import * as express from 'express' import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' -import { logger } from '../../helpers' import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' +import { logger } from '../../helpers/logger' import { processActivities } from '../../lib/activitypub/process/process' import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares' import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' -- cgit v1.2.3