diff options
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r-- | server/controllers/activitypub/client.ts | 34 | ||||
-rw-r--r-- | server/controllers/activitypub/outbox.ts | 6 |
2 files changed, 31 insertions, 9 deletions
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' | |||
3 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' | 3 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' |
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
5 | import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' | 5 | import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' |
6 | import { buildVideoAnnounce } from '../../lib/activitypub/send' | 6 | import { buildAnnounceWithVideoAudience } from '../../lib/activitypub/send' |
7 | import { audiencify, getAudience } from '../../lib/activitypub/audience' | 7 | import { audiencify, getAudience } from '../../lib/activitypub/audience' |
8 | import { createActivityData } from '../../lib/activitypub/send/send-create' | 8 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' |
9 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator, localVideoChannelValidator } from '../../middlewares' | 9 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator, localVideoChannelValidator } from '../../middlewares' |
10 | import { videosGetValidator, videosShareValidator } from '../../middlewares/validators' | 10 | import { videosGetValidator, videosShareValidator } from '../../middlewares/validators' |
11 | import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' | 11 | import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' |
@@ -26,6 +26,8 @@ import { | |||
26 | getVideoSharesActivityPubUrl | 26 | getVideoSharesActivityPubUrl |
27 | } from '../../lib/activitypub' | 27 | } from '../../lib/activitypub' |
28 | import { VideoCaptionModel } from '../../models/video/video-caption' | 28 | import { VideoCaptionModel } from '../../models/video/video-caption' |
29 | import { videoRedundancyGetValidator } from '../../middlewares/validators/redundancy' | ||
30 | import { getServerActor } from '../../helpers/utils' | ||
29 | 31 | ||
30 | const activityPubClientRouter = express.Router() | 32 | const activityPubClientRouter = express.Router() |
31 | 33 | ||
@@ -93,6 +95,11 @@ activityPubClientRouter.get('/video-channels/:name/following', | |||
93 | executeIfActivityPub(asyncMiddleware(videoChannelFollowingController)) | 95 | executeIfActivityPub(asyncMiddleware(videoChannelFollowingController)) |
94 | ) | 96 | ) |
95 | 97 | ||
98 | activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', | ||
99 | executeIfActivityPub(asyncMiddleware(videoRedundancyGetValidator)), | ||
100 | executeIfActivityPub(asyncMiddleware(videoRedundancyController)) | ||
101 | ) | ||
102 | |||
96 | // --------------------------------------------------------------------------- | 103 | // --------------------------------------------------------------------------- |
97 | 104 | ||
98 | export { | 105 | export { |
@@ -131,7 +138,7 @@ async function videoController (req: express.Request, res: express.Response, nex | |||
131 | const videoObject = audiencify(video.toActivityPubObject(), audience) | 138 | const videoObject = audiencify(video.toActivityPubObject(), audience) |
132 | 139 | ||
133 | if (req.path.endsWith('/activity')) { | 140 | if (req.path.endsWith('/activity')) { |
134 | const data = createActivityData(video.url, video.VideoChannel.Account.Actor, videoObject, audience) | 141 | const data = buildCreateActivity(video.url, video.VideoChannel.Account.Actor, videoObject, audience) |
135 | return activityPubResponse(activityPubContextify(data), res) | 142 | return activityPubResponse(activityPubContextify(data), res) |
136 | } | 143 | } |
137 | 144 | ||
@@ -140,9 +147,9 @@ async function videoController (req: express.Request, res: express.Response, nex | |||
140 | 147 | ||
141 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { | 148 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { |
142 | const share = res.locals.videoShare as VideoShareModel | 149 | const share = res.locals.videoShare as VideoShareModel |
143 | const object = await buildVideoAnnounce(share.Actor, share, res.locals.video, undefined) | 150 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined) |
144 | 151 | ||
145 | return activityPubResponse(activityPubContextify(object), res) | 152 | return activityPubResponse(activityPubContextify(activity), res) |
146 | } | 153 | } |
147 | 154 | ||
148 | async function videoAnnouncesController (req: express.Request, res: express.Response, next: express.NextFunction) { | 155 | 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 | |||
219 | const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience) | 226 | const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience) |
220 | 227 | ||
221 | if (req.path.endsWith('/activity')) { | 228 | if (req.path.endsWith('/activity')) { |
222 | const data = createActivityData(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience) | 229 | const data = buildCreateActivity(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience) |
223 | return activityPubResponse(activityPubContextify(data), res) | 230 | return activityPubResponse(activityPubContextify(data), res) |
224 | } | 231 | } |
225 | 232 | ||
226 | return activityPubResponse(activityPubContextify(videoCommentObject), res) | 233 | return activityPubResponse(activityPubContextify(videoCommentObject), res) |
227 | } | 234 | } |
228 | 235 | ||
236 | async function videoRedundancyController (req: express.Request, res: express.Response) { | ||
237 | const videoRedundancy = res.locals.videoRedundancy | ||
238 | const serverActor = await getServerActor() | ||
239 | |||
240 | const audience = getAudience(serverActor) | ||
241 | const object = audiencify(videoRedundancy.toActivityPubObject(), audience) | ||
242 | |||
243 | if (req.path.endsWith('/activity')) { | ||
244 | const data = buildCreateActivity(videoRedundancy.url, serverActor, object, audience) | ||
245 | return activityPubResponse(activityPubContextify(data), res) | ||
246 | } | ||
247 | |||
248 | return activityPubResponse(activityPubContextify(object), res) | ||
249 | } | ||
250 | |||
229 | // --------------------------------------------------------------------------- | 251 | // --------------------------------------------------------------------------- |
230 | 252 | ||
231 | async function actorFollowing (req: express.Request, actor: ActorModel) { | 253 | async function actorFollowing (req: express.Request, actor: ActorModel) { |
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index db69ae54b..bd0e4fe9d 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/controllers/activitypub/outbox.ts | |||
@@ -3,7 +3,7 @@ import { Activity } from '../../../shared/models/activitypub/activity' | |||
3 | import { VideoPrivacy } from '../../../shared/models/videos' | 3 | import { VideoPrivacy } from '../../../shared/models/videos' |
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
6 | import { announceActivityData, createActivityData } from '../../lib/activitypub/send' | 6 | import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send' |
7 | import { buildAudience } from '../../lib/activitypub/audience' | 7 | import { buildAudience } from '../../lib/activitypub/audience' |
8 | import { asyncMiddleware, localAccountValidator, localVideoChannelValidator } from '../../middlewares' | 8 | import { asyncMiddleware, localAccountValidator, localVideoChannelValidator } from '../../middlewares' |
9 | import { AccountModel } from '../../models/account/account' | 9 | import { AccountModel } from '../../models/account/account' |
@@ -60,12 +60,12 @@ async function buildActivities (actor: ActorModel, start: number, count: number) | |||
60 | // This is a shared video | 60 | // This is a shared video |
61 | if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { | 61 | if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { |
62 | const videoShare = video.VideoShares[0] | 62 | const videoShare = video.VideoShares[0] |
63 | const announceActivity = announceActivityData(videoShare.url, actor, video.url, createActivityAudience) | 63 | const announceActivity = buildAnnounceActivity(videoShare.url, actor, video.url, createActivityAudience) |
64 | 64 | ||
65 | activities.push(announceActivity) | 65 | activities.push(announceActivity) |
66 | } else { | 66 | } else { |
67 | const videoObject = video.toActivityPubObject() | 67 | const videoObject = video.toActivityPubObject() |
68 | const createActivity = createActivityData(video.url, byActor, videoObject, createActivityAudience) | 68 | const createActivity = buildCreateActivity(video.url, byActor, videoObject, createActivityAudience) |
69 | 69 | ||
70 | activities.push(createActivity) | 70 | activities.push(createActivity) |
71 | } | 71 | } |