aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/models/video/video.ts52
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'
142import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file' 141import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file'
143import { MThumbnail } from '../../typings/models/video/thumbnail' 142import { 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