X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Factivitypub%2Foutbox.ts;h=f385c9927ee5967683a01d289c590f5cf3be5dab;hb=38a3ccc7f8ad0ea94362b58c732af7c387ab46be;hp=f3dd2ad7d3e5fed8e1be89003813054cde20a24b;hpb=8d5e65349deebd499c0be10fe02d535a77d58ddb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index f3dd2ad7d..f385c9927 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/controllers/activitypub/outbox.ts @@ -1,24 +1,29 @@ -import * as express from 'express' +import express from 'express' +import { activityPubCollectionPagination } from '@server/lib/activitypub/collection' +import { activityPubContextify } from '@server/lib/activitypub/context' +import { MActorLight } from '@server/types/models' import { Activity } from '../../../shared/models/activitypub/activity' import { VideoPrivacy } from '../../../shared/models/videos' -import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' import { logger } from '../../helpers/logger' -import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send' import { buildAudience } from '../../lib/activitypub/audience' -import { asyncMiddleware, localAccountValidator, localVideoChannelValidator } from '../../middlewares' +import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send' +import { asyncMiddleware, ensureIsLocalChannel, localAccountValidator, videoChannelsNameWithHostValidator } from '../../middlewares' +import { apPaginationValidator } from '../../middlewares/validators/activitypub' import { VideoModel } from '../../models/video/video' import { activityPubResponse } from './utils' -import { MActorLight } from '@server/typings/models' const outboxRouter = express.Router() outboxRouter.get('/accounts/:name/outbox', + apPaginationValidator, localAccountValidator, asyncMiddleware(outboxController) ) -outboxRouter.get('/video-channels/:name/outbox', - localVideoChannelValidator, +outboxRouter.get('/video-channels/:nameWithHost/outbox', + apPaginationValidator, + asyncMiddleware(videoChannelsNameWithHostValidator), + ensureIsLocalChannel, asyncMiddleware(outboxController) ) @@ -38,9 +43,9 @@ async function outboxController (req: express.Request, res: express.Response) { logger.info('Receiving outbox request for %s.', actorOutboxUrl) const handler = (start: number, count: number) => buildActivities(actor, start, count) - const json = await activityPubCollectionPagination(actorOutboxUrl, handler, req.query.page) + const json = await activityPubCollectionPagination(actorOutboxUrl, handler, req.query.page, req.query.size) - return activityPubResponse(activityPubContextify(json), res) + return activityPubResponse(activityPubContextify(json, 'Collection'), res) } async function buildActivities (actor: MActorLight, start: number, count: number) {