diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-26 16:26:27 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-03-03 10:08:08 +0100 |
commit | 74d249bc1346c7cfaac7ee49bebbebcf2a01f82a (patch) | |
tree | d47bd163ae57ed8f15b445296634cc04f4f67b6f /server/models/video/video-comment.ts | |
parent | 095e2258043fcff8a79ab082d11edfbd8f13a8e2 (diff) | |
download | PeerTube-74d249bc1346c7cfaac7ee49bebbebcf2a01f82a.tar.gz PeerTube-74d249bc1346c7cfaac7ee49bebbebcf2a01f82a.tar.zst PeerTube-74d249bc1346c7cfaac7ee49bebbebcf2a01f82a.zip |
Add ability to cleanup remote AP interactions
Diffstat (limited to 'server/models/video/video-comment.ts')
-rw-r--r-- | server/models/video/video-comment.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index dc7556d44..151c2bc81 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { uniq } from 'lodash' | 1 | import { uniq } from 'lodash' |
2 | import { FindAndCountOptions, FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' | 2 | import { FindAndCountOptions, FindOptions, Op, Order, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' |
3 | import { | 3 | import { |
4 | AllowNull, | 4 | AllowNull, |
5 | BelongsTo, | 5 | BelongsTo, |
@@ -696,6 +696,18 @@ export class VideoCommentModel extends Model { | |||
696 | } | 696 | } |
697 | } | 697 | } |
698 | 698 | ||
699 | static listRemoteCommentUrlsOfLocalVideos () { | ||
700 | const query = `SELECT "videoComment".url FROM "videoComment" ` + | ||
701 | `INNER JOIN account ON account.id = "videoComment"."accountId" ` + | ||
702 | `INNER JOIN actor ON actor.id = "account"."actorId" AND actor."serverId" IS NOT NULL ` + | ||
703 | `INNER JOIN video ON video.id = "videoComment"."videoId" AND video.remote IS FALSE` | ||
704 | |||
705 | return VideoCommentModel.sequelize.query<{ url: string }>(query, { | ||
706 | type: QueryTypes.SELECT, | ||
707 | raw: true | ||
708 | }).then(rows => rows.map(r => r.url)) | ||
709 | } | ||
710 | |||
699 | static cleanOldCommentsOf (videoId: number, beforeUpdatedAt: Date) { | 711 | static cleanOldCommentsOf (videoId: number, beforeUpdatedAt: Date) { |
700 | const query = { | 712 | const query = { |
701 | where: { | 713 | where: { |