aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-comment.ts34
1 files changed, 27 insertions, 7 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 091cc2a88..c465eb3e7 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -427,8 +427,31 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
427 return VideoCommentModel.findAndCountAll<MComment>(query) 427 return VideoCommentModel.findAndCountAll<MComment>(query)
428 } 428 }
429 429
430 static async listForFeed (start: number, count: number, videoId?: number): Promise<MCommentOwnerVideoFeed[]> { 430 static async listForFeed (parameters: {
431 start: number
432 count: number
433 videoId?: number
434 accountId?: number
435 videoChannelId?: number
436 }): Promise<MCommentOwnerVideoFeed[]> {
431 const serverActor = await getServerActor() 437 const serverActor = await getServerActor()
438 const { start, count, videoId, accountId, videoChannelId } = parameters
439
440 const accountExclusion = {
441 [Op.notIn]: Sequelize.literal(
442 '(' + buildBlockedAccountSQL([ serverActor.Account.id, '"Video->VideoChannel"."accountId"' ]) + ')'
443 )
444 }
445 const accountWhere = accountId
446 ? {
447 [Op.and]: {
448 ...accountExclusion,
449 [Op.eq]: accountId
450 }
451 }
452 : accountExclusion
453
454 const videoChannelWhere = videoChannelId ? { id: videoChannelId } : undefined
432 455
433 const query = { 456 const query = {
434 order: [ [ 'createdAt', 'DESC' ] ] as Order, 457 order: [ [ 'createdAt', 'DESC' ] ] as Order,
@@ -436,11 +459,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
436 limit: count, 459 limit: count,
437 where: { 460 where: {
438 deletedAt: null, 461 deletedAt: null,
439 accountId: { 462 accountId: accountWhere
440 [Op.notIn]: Sequelize.literal(
441 '(' + buildBlockedAccountSQL([ serverActor.Account.id, '"Video->VideoChannel"."accountId"' ]) + ')'
442 )
443 }
444 }, 463 },
445 include: [ 464 include: [
446 { 465 {
@@ -454,7 +473,8 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
454 { 473 {
455 attributes: [ 'accountId' ], 474 attributes: [ 'accountId' ],
456 model: VideoChannelModel.unscoped(), 475 model: VideoChannelModel.unscoped(),
457 required: true 476 required: true,
477 where: videoChannelWhere
458 } 478 }
459 ] 479 ]
460 } 480 }