diff options
Diffstat (limited to 'server/models/video/video-comment.ts')
-rw-r--r-- | server/models/video/video-comment.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 1163f9a0e..e733138c1 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { Op } from 'sequelize' | ||
2 | import { | 3 | import { |
3 | AllowNull, | 4 | AllowNull, |
4 | BeforeDestroy, | 5 | BeforeDestroy, |
@@ -453,6 +454,19 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
453 | } | 454 | } |
454 | } | 455 | } |
455 | 456 | ||
457 | static cleanOldCommentsOf (videoId: number, beforeUpdatedAt: Date) { | ||
458 | const query = { | ||
459 | where: { | ||
460 | updatedAt: { | ||
461 | [Op.lt]: beforeUpdatedAt | ||
462 | }, | ||
463 | videoId | ||
464 | } | ||
465 | } | ||
466 | |||
467 | return VideoCommentModel.destroy(query) | ||
468 | } | ||
469 | |||
456 | getCommentStaticPath () { | 470 | getCommentStaticPath () { |
457 | return this.Video.getWatchStaticPath() + ';threadId=' + this.getThreadId() | 471 | return this.Video.getWatchStaticPath() + ';threadId=' + this.getThreadId() |
458 | } | 472 | } |