diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-20 11:21:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-20 11:21:08 +0100 |
commit | de94ac86a211dec657332d964693857ec235ce40 (patch) | |
tree | 3bff96a40e7c862d83561a26249992b07331b0a2 /server/controllers | |
parent | 3fba4b6bce69247b1d37f923894d8f44818a891c (diff) | |
download | PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.gz PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.zst PeerTube-de94ac86a211dec657332d964693857ec235ce40.zip |
Fix incorrect IDs in AP federation
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 56 | ||||
-rw-r--r-- | server/controllers/api/server/follows.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/video-playlist.ts | 46 | ||||
-rw-r--r-- | server/controllers/api/videos/import.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/live.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/rate.ts | 6 |
7 files changed, 72 insertions, 50 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index d85d0aa5f..71a5b6232 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import * as cors from 'cors' | 1 | import * as cors from 'cors' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { getRateUrl } from '@server/lib/activitypub/video-rates' | ||
4 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
5 | import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models' | 4 | import { MAccountId, MActorId, MChannelId, MVideoId, MVideoUrl } from '@server/types/models' |
6 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' | 5 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' |
7 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 6 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
8 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 7 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
@@ -12,10 +11,10 @@ import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/act | |||
12 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' | 11 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' |
13 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' | 12 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' |
14 | import { | 13 | import { |
15 | getVideoCommentsActivityPubUrl, | 14 | getLocalVideoCommentsActivityPubUrl, |
16 | getVideoDislikesActivityPubUrl, | 15 | getLocalVideoDislikesActivityPubUrl, |
17 | getVideoLikesActivityPubUrl, | 16 | getLocalVideoLikesActivityPubUrl, |
18 | getVideoSharesActivityPubUrl | 17 | getLocalVideoSharesActivityPubUrl |
19 | } from '../../lib/activitypub/url' | 18 | } from '../../lib/activitypub/url' |
20 | import { | 19 | import { |
21 | asyncMiddleware, | 20 | asyncMiddleware, |
@@ -212,10 +211,9 @@ function getAccountVideoRateFactory (rateType: VideoRateType) { | |||
212 | const accountVideoRate = res.locals.accountVideoRate | 211 | const accountVideoRate = res.locals.accountVideoRate |
213 | 212 | ||
214 | const byActor = accountVideoRate.Account.Actor | 213 | const byActor = accountVideoRate.Account.Actor |
215 | const url = getRateUrl(rateType, byActor, accountVideoRate.Video) | ||
216 | const APObject = rateType === 'like' | 214 | const APObject = rateType === 'like' |
217 | ? buildLikeActivity(url, byActor, accountVideoRate.Video) | 215 | ? buildLikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video) |
218 | : buildDislikeActivity(url, byActor, accountVideoRate.Video) | 216 | : buildDislikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video) |
219 | 217 | ||
220 | return activityPubResponse(activityPubContextify(APObject), res) | 218 | return activityPubResponse(activityPubContextify(APObject), res) |
221 | } | 219 | } |
@@ -225,7 +223,7 @@ async function videoController (req: express.Request, res: express.Response) { | |||
225 | // We need more attributes | 223 | // We need more attributes |
226 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(res.locals.onlyVideoWithRights.id) | 224 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(res.locals.onlyVideoWithRights.id) |
227 | 225 | ||
228 | if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) | 226 | if (redirectIfNotOwned(video.url, res)) return |
229 | 227 | ||
230 | // We need captions to render AP object | 228 | // We need captions to render AP object |
231 | const captions = await VideoCaptionModel.listVideoCaptions(video.id) | 229 | const captions = await VideoCaptionModel.listVideoCaptions(video.id) |
@@ -245,7 +243,7 @@ async function videoController (req: express.Request, res: express.Response) { | |||
245 | async function videoAnnounceController (req: express.Request, res: express.Response) { | 243 | async function videoAnnounceController (req: express.Request, res: express.Response) { |
246 | const share = res.locals.videoShare | 244 | const share = res.locals.videoShare |
247 | 245 | ||
248 | if (share.url.startsWith(WEBSERVER.URL) === false) return res.redirect(share.url) | 246 | if (redirectIfNotOwned(share.url, res)) return |
249 | 247 | ||
250 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoAll, undefined) | 248 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoAll, undefined) |
251 | 249 | ||
@@ -255,6 +253,8 @@ async function videoAnnounceController (req: express.Request, res: express.Respo | |||
255 | async function videoAnnouncesController (req: express.Request, res: express.Response) { | 253 | async function videoAnnouncesController (req: express.Request, res: express.Response) { |
256 | const video = res.locals.onlyImmutableVideo | 254 | const video = res.locals.onlyImmutableVideo |
257 | 255 | ||
256 | if (redirectIfNotOwned(video.url, res)) return | ||
257 | |||
258 | const handler = async (start: number, count: number) => { | 258 | const handler = async (start: number, count: number) => { |
259 | const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count) | 259 | const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count) |
260 | return { | 260 | return { |
@@ -262,21 +262,27 @@ async function videoAnnouncesController (req: express.Request, res: express.Resp | |||
262 | data: result.rows.map(r => r.url) | 262 | data: result.rows.map(r => r.url) |
263 | } | 263 | } |
264 | } | 264 | } |
265 | const json = await activityPubCollectionPagination(getVideoSharesActivityPubUrl(video), handler, req.query.page) | 265 | const json = await activityPubCollectionPagination(getLocalVideoSharesActivityPubUrl(video), handler, req.query.page) |
266 | 266 | ||
267 | return activityPubResponse(activityPubContextify(json), res) | 267 | return activityPubResponse(activityPubContextify(json), res) |
268 | } | 268 | } |
269 | 269 | ||
270 | async function videoLikesController (req: express.Request, res: express.Response) { | 270 | async function videoLikesController (req: express.Request, res: express.Response) { |
271 | const video = res.locals.onlyImmutableVideo | 271 | const video = res.locals.onlyImmutableVideo |
272 | const json = await videoRates(req, 'like', video, getVideoLikesActivityPubUrl(video)) | 272 | |
273 | if (redirectIfNotOwned(video.url, res)) return | ||
274 | |||
275 | const json = await videoRates(req, 'like', video, getLocalVideoLikesActivityPubUrl(video)) | ||
273 | 276 | ||
274 | return activityPubResponse(activityPubContextify(json), res) | 277 | return activityPubResponse(activityPubContextify(json), res) |
275 | } | 278 | } |
276 | 279 | ||
277 | async function videoDislikesController (req: express.Request, res: express.Response) { | 280 | async function videoDislikesController (req: express.Request, res: express.Response) { |
278 | const video = res.locals.onlyImmutableVideo | 281 | const video = res.locals.onlyImmutableVideo |
279 | const json = await videoRates(req, 'dislike', video, getVideoDislikesActivityPubUrl(video)) | 282 | |
283 | if (redirectIfNotOwned(video.url, res)) return | ||
284 | |||
285 | const json = await videoRates(req, 'dislike', video, getLocalVideoDislikesActivityPubUrl(video)) | ||
280 | 286 | ||
281 | return activityPubResponse(activityPubContextify(json), res) | 287 | return activityPubResponse(activityPubContextify(json), res) |
282 | } | 288 | } |
@@ -284,6 +290,8 @@ async function videoDislikesController (req: express.Request, res: express.Respo | |||
284 | async function videoCommentsController (req: express.Request, res: express.Response) { | 290 | async function videoCommentsController (req: express.Request, res: express.Response) { |
285 | const video = res.locals.onlyImmutableVideo | 291 | const video = res.locals.onlyImmutableVideo |
286 | 292 | ||
293 | if (redirectIfNotOwned(video.url, res)) return | ||
294 | |||
287 | const handler = async (start: number, count: number) => { | 295 | const handler = async (start: number, count: number) => { |
288 | const result = await VideoCommentModel.listAndCountByVideoForAP(video, start, count) | 296 | const result = await VideoCommentModel.listAndCountByVideoForAP(video, start, count) |
289 | return { | 297 | return { |
@@ -291,7 +299,7 @@ async function videoCommentsController (req: express.Request, res: express.Respo | |||
291 | data: result.rows.map(r => r.url) | 299 | data: result.rows.map(r => r.url) |
292 | } | 300 | } |
293 | } | 301 | } |
294 | const json = await activityPubCollectionPagination(getVideoCommentsActivityPubUrl(video), handler, req.query.page) | 302 | const json = await activityPubCollectionPagination(getLocalVideoCommentsActivityPubUrl(video), handler, req.query.page) |
295 | 303 | ||
296 | return activityPubResponse(activityPubContextify(json), res) | 304 | return activityPubResponse(activityPubContextify(json), res) |
297 | } | 305 | } |
@@ -319,7 +327,7 @@ async function videoChannelFollowingController (req: express.Request, res: expre | |||
319 | async function videoCommentController (req: express.Request, res: express.Response) { | 327 | async function videoCommentController (req: express.Request, res: express.Response) { |
320 | const videoComment = res.locals.videoCommentFull | 328 | const videoComment = res.locals.videoCommentFull |
321 | 329 | ||
322 | if (videoComment.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoComment.url) | 330 | if (redirectIfNotOwned(videoComment.url, res)) return |
323 | 331 | ||
324 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) | 332 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) |
325 | const isPublic = true // Comments are always public | 333 | const isPublic = true // Comments are always public |
@@ -340,7 +348,8 @@ async function videoCommentController (req: express.Request, res: express.Respon | |||
340 | 348 | ||
341 | async function videoRedundancyController (req: express.Request, res: express.Response) { | 349 | async function videoRedundancyController (req: express.Request, res: express.Response) { |
342 | const videoRedundancy = res.locals.videoRedundancy | 350 | const videoRedundancy = res.locals.videoRedundancy |
343 | if (videoRedundancy.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url) | 351 | |
352 | if (redirectIfNotOwned(videoRedundancy.url, res)) return | ||
344 | 353 | ||
345 | const serverActor = await getServerActor() | 354 | const serverActor = await getServerActor() |
346 | 355 | ||
@@ -358,6 +367,8 @@ async function videoRedundancyController (req: express.Request, res: express.Res | |||
358 | async function videoPlaylistController (req: express.Request, res: express.Response) { | 367 | async function videoPlaylistController (req: express.Request, res: express.Response) { |
359 | const playlist = res.locals.videoPlaylistFull | 368 | const playlist = res.locals.videoPlaylistFull |
360 | 369 | ||
370 | if (redirectIfNotOwned(playlist.url, res)) return | ||
371 | |||
361 | // We need more attributes | 372 | // We need more attributes |
362 | playlist.OwnerAccount = await AccountModel.load(playlist.ownerAccountId) | 373 | playlist.OwnerAccount = await AccountModel.load(playlist.ownerAccountId) |
363 | 374 | ||
@@ -371,6 +382,8 @@ async function videoPlaylistController (req: express.Request, res: express.Respo | |||
371 | function videoPlaylistElementController (req: express.Request, res: express.Response) { | 382 | function videoPlaylistElementController (req: express.Request, res: express.Response) { |
372 | const videoPlaylistElement = res.locals.videoPlaylistElementAP | 383 | const videoPlaylistElement = res.locals.videoPlaylistElementAP |
373 | 384 | ||
385 | if (redirectIfNotOwned(videoPlaylistElement.url, res)) return | ||
386 | |||
374 | const json = videoPlaylistElement.toActivityPubObject() | 387 | const json = videoPlaylistElement.toActivityPubObject() |
375 | return activityPubResponse(activityPubContextify(json), res) | 388 | return activityPubResponse(activityPubContextify(json), res) |
376 | } | 389 | } |
@@ -411,3 +424,12 @@ function videoRates (req: express.Request, rateType: VideoRateType, video: MVide | |||
411 | } | 424 | } |
412 | return activityPubCollectionPagination(url, handler, req.query.page) | 425 | return activityPubCollectionPagination(url, handler, req.query.page) |
413 | } | 426 | } |
427 | |||
428 | function redirectIfNotOwned (url: string, res: express.Response) { | ||
429 | if (url.startsWith(WEBSERVER.URL) === false) { | ||
430 | res.redirect(url) | ||
431 | return true | ||
432 | } | ||
433 | |||
434 | return false | ||
435 | } | ||
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 23823c9fb..517d1897e 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -165,7 +165,7 @@ async function removeFollowing (req: express.Request, res: express.Response) { | |||
165 | async function removeOrRejectFollower (req: express.Request, res: express.Response) { | 165 | async function removeOrRejectFollower (req: express.Request, res: express.Response) { |
166 | const follow = res.locals.follow | 166 | const follow = res.locals.follow |
167 | 167 | ||
168 | await sendReject(follow.ActorFollower, follow.ActorFollowing) | 168 | await sendReject(follow.url, follow.ActorFollower, follow.ActorFollowing) |
169 | 169 | ||
170 | await follow.destroy() | 170 | await follow.destroy() |
171 | 171 | ||
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 41a0e07ff..fb08a63b2 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -1,5 +1,24 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { join } from 'path' | ||
3 | import { getServerActor } from '@server/models/application/application' | ||
4 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' | ||
5 | import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' | ||
6 | import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' | ||
7 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' | ||
8 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
9 | import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' | ||
10 | import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' | ||
11 | import { resetSequelizeInstance } from '../../helpers/database-utils' | ||
12 | import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils' | ||
13 | import { logger } from '../../helpers/logger' | ||
2 | import { getFormattedObjects } from '../../helpers/utils' | 14 | import { getFormattedObjects } from '../../helpers/utils' |
15 | import { CONFIG } from '../../initializers/config' | ||
16 | import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' | ||
17 | import { sequelizeTypescript } from '../../initializers/database' | ||
18 | import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' | ||
19 | import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' | ||
20 | import { JobQueue } from '../../lib/job-queue' | ||
21 | import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail' | ||
3 | import { | 22 | import { |
4 | asyncMiddleware, | 23 | asyncMiddleware, |
5 | asyncRetryTransactionMiddleware, | 24 | asyncRetryTransactionMiddleware, |
@@ -10,11 +29,6 @@ import { | |||
10 | setDefaultSort | 29 | setDefaultSort |
11 | } from '../../middlewares' | 30 | } from '../../middlewares' |
12 | import { videoPlaylistsSortValidator } from '../../middlewares/validators' | 31 | import { videoPlaylistsSortValidator } from '../../middlewares/validators' |
13 | import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils' | ||
14 | import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' | ||
15 | import { logger } from '../../helpers/logger' | ||
16 | import { resetSequelizeInstance } from '../../helpers/database-utils' | ||
17 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | ||
18 | import { | 32 | import { |
19 | commonVideoPlaylistFiltersValidator, | 33 | commonVideoPlaylistFiltersValidator, |
20 | videoPlaylistsAddValidator, | 34 | videoPlaylistsAddValidator, |
@@ -25,23 +39,9 @@ import { | |||
25 | videoPlaylistsUpdateOrRemoveVideoValidator, | 39 | videoPlaylistsUpdateOrRemoveVideoValidator, |
26 | videoPlaylistsUpdateValidator | 40 | videoPlaylistsUpdateValidator |
27 | } from '../../middlewares/validators/videos/video-playlists' | 41 | } from '../../middlewares/validators/videos/video-playlists' |
28 | import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' | ||
29 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
30 | import { join } from 'path' | ||
31 | import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' | ||
32 | import { getVideoPlaylistActivityPubUrl, getVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' | ||
33 | import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' | ||
34 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' | ||
35 | import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' | ||
36 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' | ||
37 | import { AccountModel } from '../../models/account/account' | 42 | import { AccountModel } from '../../models/account/account' |
38 | import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' | 43 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
39 | import { JobQueue } from '../../lib/job-queue' | 44 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' |
40 | import { CONFIG } from '../../initializers/config' | ||
41 | import { sequelizeTypescript } from '../../initializers/database' | ||
42 | import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail' | ||
43 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' | ||
44 | import { getServerActor } from '@server/models/application/application' | ||
45 | 45 | ||
46 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) | 46 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) |
47 | 47 | ||
@@ -161,7 +161,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) { | |||
161 | ownerAccountId: user.Account.id | 161 | ownerAccountId: user.Account.id |
162 | }) as MVideoPlaylistFull | 162 | }) as MVideoPlaylistFull |
163 | 163 | ||
164 | videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object | 164 | videoPlaylist.url = getLocalVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object |
165 | 165 | ||
166 | if (videoPlaylistInfo.videoChannelId) { | 166 | if (videoPlaylistInfo.videoChannelId) { |
167 | const videoChannel = res.locals.videoChannel | 167 | const videoChannel = res.locals.videoChannel |
@@ -304,7 +304,7 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response) | |||
304 | videoId: video.id | 304 | videoId: video.id |
305 | }, { transaction: t }) | 305 | }, { transaction: t }) |
306 | 306 | ||
307 | playlistElement.url = getVideoPlaylistElementActivityPubUrl(videoPlaylist, playlistElement) | 307 | playlistElement.url = getLocalVideoPlaylistElementActivityPubUrl(videoPlaylist, playlistElement) |
308 | await playlistElement.save({ transaction: t }) | 308 | await playlistElement.save({ transaction: t }) |
309 | 309 | ||
310 | videoPlaylist.changed('updatedAt', true) | 310 | videoPlaylist.changed('updatedAt', true) |
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 5840cd063..bc5fea7aa 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -28,7 +28,7 @@ import { getYoutubeDLInfo, getYoutubeDLSubs, YoutubeDLInfo } from '../../../help | |||
28 | import { CONFIG } from '../../../initializers/config' | 28 | import { CONFIG } from '../../../initializers/config' |
29 | import { MIMETYPES } from '../../../initializers/constants' | 29 | import { MIMETYPES } from '../../../initializers/constants' |
30 | import { sequelizeTypescript } from '../../../initializers/database' | 30 | import { sequelizeTypescript } from '../../../initializers/database' |
31 | import { getVideoActivityPubUrl } from '../../../lib/activitypub/url' | 31 | import { getLocalVideoActivityPubUrl } from '../../../lib/activitypub/url' |
32 | import { JobQueue } from '../../../lib/job-queue/job-queue' | 32 | import { JobQueue } from '../../../lib/job-queue/job-queue' |
33 | import { createVideoMiniatureFromExisting, createVideoMiniatureFromUrl } from '../../../lib/thumbnail' | 33 | import { createVideoMiniatureFromExisting, createVideoMiniatureFromUrl } from '../../../lib/thumbnail' |
34 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | 34 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' |
@@ -250,7 +250,7 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You | |||
250 | originallyPublishedAt: body.originallyPublishedAt || importData.originallyPublishedAt | 250 | originallyPublishedAt: body.originallyPublishedAt || importData.originallyPublishedAt |
251 | } | 251 | } |
252 | const video = new VideoModel(videoData) | 252 | const video = new VideoModel(videoData) |
253 | video.url = getVideoActivityPubUrl(video) | 253 | video.url = getLocalVideoActivityPubUrl(video) |
254 | 254 | ||
255 | return video | 255 | return video |
256 | } | 256 | } |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index bfebc54ed..b5ff2e72e 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -5,7 +5,7 @@ import toInt from 'validator/lib/toInt' | |||
5 | import { addOptimizeOrMergeAudioJob } from '@server/helpers/video' | 5 | import { addOptimizeOrMergeAudioJob } from '@server/helpers/video' |
6 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 6 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
7 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' | 7 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' |
8 | import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' | 8 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
9 | import { LiveManager } from '@server/lib/live-manager' | 9 | import { LiveManager } from '@server/lib/live-manager' |
10 | import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' | 10 | import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' |
11 | import { getVideoFilePath } from '@server/lib/video-paths' | 11 | import { getVideoFilePath } from '@server/lib/video-paths' |
@@ -189,7 +189,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
189 | videoData.duration = videoPhysicalFile['duration'] // duration was added by a previous middleware | 189 | videoData.duration = videoPhysicalFile['duration'] // duration was added by a previous middleware |
190 | 190 | ||
191 | const video = new VideoModel(videoData) as MVideoFullLight | 191 | const video = new VideoModel(videoData) as MVideoFullLight |
192 | video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object | 192 | video.url = getLocalVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object |
193 | 193 | ||
194 | const videoFile = new VideoFileModel({ | 194 | const videoFile = new VideoFileModel({ |
195 | extname: extname(videoPhysicalFile.filename), | 195 | extname: extname(videoPhysicalFile.filename), |
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index d438b6f3a..a6f00c1bd 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts | |||
@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid' | |||
3 | import { createReqFiles } from '@server/helpers/express-utils' | 3 | import { createReqFiles } from '@server/helpers/express-utils' |
4 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
5 | import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' | 5 | import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' |
6 | import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' | 6 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
7 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | 7 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' |
8 | import { Hooks } from '@server/lib/plugins/hooks' | 8 | import { Hooks } from '@server/lib/plugins/hooks' |
9 | import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' | 9 | import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' |
@@ -86,7 +86,7 @@ async function addLiveVideo (req: express.Request, res: express.Response) { | |||
86 | videoData.duration = 0 | 86 | videoData.duration = 0 |
87 | 87 | ||
88 | const video = new VideoModel(videoData) as MVideoDetails | 88 | const video = new VideoModel(videoData) as MVideoDetails |
89 | video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object | 89 | video.url = getLocalVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object |
90 | 90 | ||
91 | const videoLive = new VideoLiveModel() | 91 | const videoLive = new VideoLiveModel() |
92 | videoLive.saveReplay = videoInfo.saveReplay || false | 92 | videoLive.saveReplay = videoInfo.saveReplay || false |
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 3ee365289..df1eddb4f 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { UserVideoRateUpdate } from '../../../../shared' | 2 | import { UserVideoRateUpdate } from '../../../../shared' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { VIDEO_RATE_TYPES } from '../../../initializers/constants' | 4 | import { VIDEO_RATE_TYPES } from '../../../initializers/constants' |
5 | import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates' | 5 | import { getLocalRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates' |
6 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' | 6 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' |
7 | import { AccountModel } from '../../../models/account/account' | 7 | import { AccountModel } from '../../../models/account/account' |
8 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 8 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
@@ -52,7 +52,7 @@ async function rateVideo (req: express.Request, res: express.Response) { | |||
52 | await previousRate.destroy(sequelizeOptions) | 52 | await previousRate.destroy(sequelizeOptions) |
53 | } else { // Update previous rate | 53 | } else { // Update previous rate |
54 | previousRate.type = rateType | 54 | previousRate.type = rateType |
55 | previousRate.url = getRateUrl(rateType, userAccount.Actor, videoInstance) | 55 | previousRate.url = getLocalRateUrl(rateType, userAccount.Actor, videoInstance) |
56 | await previousRate.save(sequelizeOptions) | 56 | await previousRate.save(sequelizeOptions) |
57 | } | 57 | } |
58 | } else if (rateType !== 'none') { // There was not a previous rate, insert a new one if there is a rate | 58 | } else if (rateType !== 'none') { // There was not a previous rate, insert a new one if there is a rate |
@@ -60,7 +60,7 @@ async function rateVideo (req: express.Request, res: express.Response) { | |||
60 | accountId: accountInstance.id, | 60 | accountId: accountInstance.id, |
61 | videoId: videoInstance.id, | 61 | videoId: videoInstance.id, |
62 | type: rateType, | 62 | type: rateType, |
63 | url: getRateUrl(rateType, userAccount.Actor, videoInstance) | 63 | url: getLocalRateUrl(rateType, userAccount.Actor, videoInstance) |
64 | } | 64 | } |
65 | 65 | ||
66 | await AccountVideoRateModel.create(query, sequelizeOptions) | 66 | await AccountVideoRateModel.create(query, sequelizeOptions) |