X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Factivitypub%2Fclient.ts;h=2e168ea78812c6876fa158e685ca60f09f72daa7;hb=c48e82b5e0478434de30626d14594a97f2402e7c;hp=54cf44419f6f0a99b90e26b2387c9593e9bf929b;hpb=a651038487faa838bda3ce04695b08bc65baff70;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 54cf44419..2e168ea78 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -3,9 +3,9 @@ import * as express from 'express' import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' -import { buildVideoAnnounce } from '../../lib/activitypub/send' +import { buildAnnounceWithVideoAudience } from '../../lib/activitypub/send' import { audiencify, getAudience } from '../../lib/activitypub/audience' -import { createActivityData } from '../../lib/activitypub/send/send-create' +import { buildCreateActivity } from '../../lib/activitypub/send/send-create' import { asyncMiddleware, executeIfActivityPub, localAccountValidator, localVideoChannelValidator } from '../../middlewares' import { videosGetValidator, videosShareValidator } from '../../middlewares/validators' import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' @@ -26,6 +26,8 @@ import { getVideoSharesActivityPubUrl } from '../../lib/activitypub' import { VideoCaptionModel } from '../../models/video/video-caption' +import { videoRedundancyGetValidator } from '../../middlewares/validators/redundancy' +import { getServerActor } from '../../helpers/utils' const activityPubClientRouter = express.Router() @@ -93,6 +95,11 @@ activityPubClientRouter.get('/video-channels/:name/following', executeIfActivityPub(asyncMiddleware(videoChannelFollowingController)) ) +activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', + executeIfActivityPub(asyncMiddleware(videoRedundancyGetValidator)), + executeIfActivityPub(asyncMiddleware(videoRedundancyController)) +) + // --------------------------------------------------------------------------- export { @@ -131,7 +138,7 @@ async function videoController (req: express.Request, res: express.Response, nex const videoObject = audiencify(video.toActivityPubObject(), audience) if (req.path.endsWith('/activity')) { - const data = createActivityData(video.url, video.VideoChannel.Account.Actor, videoObject, audience) + const data = buildCreateActivity(video.url, video.VideoChannel.Account.Actor, videoObject, audience) return activityPubResponse(activityPubContextify(data), res) } @@ -140,9 +147,9 @@ async function videoController (req: express.Request, res: express.Response, nex async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { const share = res.locals.videoShare as VideoShareModel - const object = await buildVideoAnnounce(share.Actor, share, res.locals.video, undefined) + const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined) - return activityPubResponse(activityPubContextify(object), res) + return activityPubResponse(activityPubContextify(activity), res) } async function videoAnnouncesController (req: express.Request, res: express.Response, next: express.NextFunction) { @@ -219,13 +226,28 @@ async function videoCommentController (req: express.Request, res: express.Respon const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience) if (req.path.endsWith('/activity')) { - const data = createActivityData(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience) + const data = buildCreateActivity(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience) return activityPubResponse(activityPubContextify(data), res) } return activityPubResponse(activityPubContextify(videoCommentObject), res) } +async function videoRedundancyController (req: express.Request, res: express.Response) { + const videoRedundancy = res.locals.videoRedundancy + const serverActor = await getServerActor() + + const audience = getAudience(serverActor) + const object = audiencify(videoRedundancy.toActivityPubObject(), audience) + + if (req.path.endsWith('/activity')) { + const data = buildCreateActivity(videoRedundancy.url, serverActor, object, audience) + return activityPubResponse(activityPubContextify(data), res) + } + + return activityPubResponse(activityPubContextify(object), res) +} + // --------------------------------------------------------------------------- async function actorFollowing (req: express.Request, actor: ActorModel) {