aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-comment.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-19 16:23:02 +0100
committerChocobozzz <me@florianbigard.com>2019-03-19 16:23:02 +0100
commit2ba92871319d7af63472c1380664a9f9eeb1c690 (patch)
treed593b2dfea29a8171b9f6afaaef076321f5edf71 /server/models/video/video-comment.ts
parentd74d29ad9e35929491cf37223398d2535ab23de0 (diff)
downloadPeerTube-2ba92871319d7af63472c1380664a9f9eeb1c690.tar.gz
PeerTube-2ba92871319d7af63472c1380664a9f9eeb1c690.tar.zst
PeerTube-2ba92871319d7af63472c1380664a9f9eeb1c690.zip
Cleanup invalid rates/comments/shares
Diffstat (limited to 'server/models/video/video-comment.ts')
-rw-r--r--server/models/video/video-comment.ts14
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 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { Op } from 'sequelize'
2import { 3import {
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 }