diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-27 09:09:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-27 09:09:50 +0100 |
commit | 16ec5e0833a4f72e75ca2a4f4be00f0453c68c80 (patch) | |
tree | 5b33355cebd25e57cf4695ac59ada14c087c083c /server/models/video | |
parent | e81871782db9927b2eb14b5deeb03b4e7b3cce0a (diff) | |
parent | 195ba6cdf38f4515a514cf8432930576539b0a04 (diff) | |
download | PeerTube-16ec5e0833a4f72e75ca2a4f4be00f0453c68c80.tar.gz PeerTube-16ec5e0833a4f72e75ca2a4f4be00f0453c68c80.tar.zst PeerTube-16ec5e0833a4f72e75ca2a4f4be00f0453c68c80.zip |
Merge branch 'release/2.1.0'
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video.ts | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index eacffe186..a91a7663d 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -136,8 +136,7 @@ import { | |||
136 | MVideoThumbnailBlacklist, | 136 | MVideoThumbnailBlacklist, |
137 | MVideoWithAllFiles, | 137 | MVideoWithAllFiles, |
138 | MVideoWithFile, | 138 | MVideoWithFile, |
139 | MVideoWithRights, | 139 | MVideoWithRights |
140 | MStreamingPlaylistFiles | ||
141 | } from '../../typings/models' | 140 | } from '../../typings/models' |
142 | import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file' | 141 | import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file' |
143 | import { MThumbnail } from '../../typings/models/video/thumbnail' | 142 | import { MThumbnail } from '../../typings/models/video/thumbnail' |
@@ -437,42 +436,31 @@ export type AvailableForListIDsOptions = { | |||
437 | } | 436 | } |
438 | 437 | ||
439 | if (options.followerActorId) { | 438 | if (options.followerActorId) { |
440 | let localVideosReq: WhereOptions = {} | 439 | let localVideosReq = '' |
441 | if (options.includeLocalVideos === true) { | 440 | if (options.includeLocalVideos === true) { |
442 | localVideosReq = { remote: false } | 441 | localVideosReq = ' UNION ALL SELECT "video"."id" FROM "video" WHERE remote IS FALSE' |
443 | } | 442 | } |
444 | 443 | ||
445 | // Force actorId to be a number to avoid SQL injections | 444 | // Force actorId to be a number to avoid SQL injections |
446 | const actorIdNumber = parseInt(options.followerActorId.toString(), 10) | 445 | const actorIdNumber = parseInt(options.followerActorId.toString(), 10) |
447 | whereAnd.push({ | 446 | whereAnd.push({ |
448 | [Op.or]: [ | 447 | id: { |
449 | { | 448 | [Op.in]: Sequelize.literal( |
450 | id: { | 449 | '(' + |
451 | [ Op.in ]: Sequelize.literal( | 450 | 'SELECT "videoShare"."videoId" AS "id" FROM "videoShare" ' + |
452 | '(' + | 451 | 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' + |
453 | 'SELECT "videoShare"."videoId" AS "id" FROM "videoShare" ' + | 452 | 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + |
454 | 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' + | 453 | ' UNION ALL ' + |
455 | 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + | 454 | 'SELECT "video"."id" AS "id" FROM "video" ' + |
456 | ')' | 455 | 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' + |
457 | ) | 456 | 'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' + |
458 | } | 457 | 'INNER JOIN "actor" ON "account"."actorId" = "actor"."id" ' + |
459 | }, | 458 | 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "actor"."id" ' + |
460 | { | 459 | 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + |
461 | id: { | 460 | localVideosReq + |
462 | [ Op.in ]: Sequelize.literal( | 461 | ')' |
463 | '(' + | 462 | ) |
464 | 'SELECT "video"."id" AS "id" FROM "video" ' + | 463 | } |
465 | 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' + | ||
466 | 'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' + | ||
467 | 'INNER JOIN "actor" ON "account"."actorId" = "actor"."id" ' + | ||
468 | 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "actor"."id" ' + | ||
469 | 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + | ||
470 | ')' | ||
471 | ) | ||
472 | } | ||
473 | }, | ||
474 | localVideosReq | ||
475 | ] | ||
476 | }) | 464 | }) |
477 | } | 465 | } |
478 | 466 | ||