diff options
Diffstat (limited to 'server/models/video/video-share.ts')
-rw-r--r-- | server/models/video/video-share.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index b7f5f3fa3..5059c1fa6 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { literal, Op, Transaction } from 'sequelize' | 1 | import { literal, Op, QueryTypes, Transaction } from 'sequelize' |
2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 3 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
@@ -185,6 +185,17 @@ export class VideoShareModel extends Model { | |||
185 | return VideoShareModel.findAndCountAll(query) | 185 | return VideoShareModel.findAndCountAll(query) |
186 | } | 186 | } |
187 | 187 | ||
188 | static listRemoteShareUrlsOfLocalVideos () { | ||
189 | const query = `SELECT "videoShare".url FROM "videoShare" ` + | ||
190 | `INNER JOIN actor ON actor.id = "videoShare"."actorId" AND actor."serverId" IS NOT NULL ` + | ||
191 | `INNER JOIN video ON video.id = "videoShare"."videoId" AND video.remote IS FALSE` | ||
192 | |||
193 | return VideoShareModel.sequelize.query<{ url: string }>(query, { | ||
194 | type: QueryTypes.SELECT, | ||
195 | raw: true | ||
196 | }).then(rows => rows.map(r => r.url)) | ||
197 | } | ||
198 | |||
188 | static cleanOldSharesOf (videoId: number, beforeUpdatedAt: Date) { | 199 | static cleanOldSharesOf (videoId: number, beforeUpdatedAt: Date) { |
189 | const query = { | 200 | const query = { |
190 | where: { | 201 | where: { |