diff options
author | Chocobozzz <me@florianbigard.com> | 2023-01-10 11:09:30 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-01-10 11:56:08 +0100 |
commit | 8c4bbd946d2247c2e239cbbf8773d2d31c1a57aa (patch) | |
tree | 4e7d3711cccb095d4356c59554bdfd4e16502832 /server/models/video | |
parent | a8749f7c3b137f433e6944bb99fd721a6f0cfc1e (diff) | |
download | PeerTube-8c4bbd946d2247c2e239cbbf8773d2d31c1a57aa.tar.gz PeerTube-8c4bbd946d2247c2e239cbbf8773d2d31c1a57aa.tar.zst PeerTube-8c4bbd946d2247c2e239cbbf8773d2d31c1a57aa.zip |
Refactor model utils
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/sql/comment/video-comment-list-query-builder.ts | 2 | ||||
-rw-r--r-- | server/models/video/sql/video/shared/abstract-video-query-builder.ts | 2 | ||||
-rw-r--r-- | server/models/video/sql/video/videos-id-list-query-builder.ts | 7 | ||||
-rw-r--r-- | server/models/video/tag.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-blacklist.ts | 6 | ||||
-rw-r--r-- | server/models/video/video-caption.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-change-ownership.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-channel-sync.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 12 | ||||
-rw-r--r-- | server/models/video/video-comment.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-file.ts | 11 | ||||
-rw-r--r-- | server/models/video/video-import.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-playlist-element.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-playlist.ts | 12 | ||||
-rw-r--r-- | server/models/video/video-share.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 7 | ||||
-rw-r--r-- | server/models/video/video.ts | 7 |
17 files changed, 41 insertions, 41 deletions
diff --git a/server/models/video/sql/comment/video-comment-list-query-builder.ts b/server/models/video/sql/comment/video-comment-list-query-builder.ts index 49b41b6d8..3960f6b13 100644 --- a/server/models/video/sql/comment/video-comment-list-query-builder.ts +++ b/server/models/video/sql/comment/video-comment-list-query-builder.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Model, Sequelize, Transaction } from 'sequelize' | 1 | import { Model, Sequelize, Transaction } from 'sequelize' |
2 | import { AbstractRunQuery, ModelBuilder } from '@server/models/shared' | 2 | import { AbstractRunQuery, ModelBuilder } from '@server/models/shared' |
3 | import { createSafeIn, getCommentSort, parseRowCountResult } from '@server/models/utils' | ||
4 | import { ActorImageType, VideoPrivacy } from '@shared/models' | 3 | import { ActorImageType, VideoPrivacy } from '@shared/models' |
4 | import { createSafeIn, getCommentSort, parseRowCountResult } from '../../../shared' | ||
5 | import { VideoCommentTableAttributes } from './video-comment-table-attributes' | 5 | import { VideoCommentTableAttributes } from './video-comment-table-attributes' |
6 | 6 | ||
7 | export interface ListVideoCommentsOptions { | 7 | export interface ListVideoCommentsOptions { |
diff --git a/server/models/video/sql/video/shared/abstract-video-query-builder.ts b/server/models/video/sql/video/shared/abstract-video-query-builder.ts index f0ce69501..cbd57ad8c 100644 --- a/server/models/video/sql/video/shared/abstract-video-query-builder.ts +++ b/server/models/video/sql/video/shared/abstract-video-query-builder.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { Sequelize } from 'sequelize' | 1 | import { Sequelize } from 'sequelize' |
2 | import validator from 'validator' | 2 | import validator from 'validator' |
3 | import { createSafeIn } from '@server/models/utils' | ||
4 | import { MUserAccountId } from '@server/types/models' | 3 | import { MUserAccountId } from '@server/types/models' |
5 | import { ActorImageType } from '@shared/models' | 4 | import { ActorImageType } from '@shared/models' |
6 | import { AbstractRunQuery } from '../../../../shared/abstract-run-query' | 5 | import { AbstractRunQuery } from '../../../../shared/abstract-run-query' |
6 | import { createSafeIn } from '../../../../shared' | ||
7 | import { VideoTableAttributes } from './video-table-attributes' | 7 | import { VideoTableAttributes } from './video-table-attributes' |
8 | 8 | ||
9 | /** | 9 | /** |
diff --git a/server/models/video/sql/video/videos-id-list-query-builder.ts b/server/models/video/sql/video/videos-id-list-query-builder.ts index 7c864bf27..62f1855c7 100644 --- a/server/models/video/sql/video/videos-id-list-query-builder.ts +++ b/server/models/video/sql/video/videos-id-list-query-builder.ts | |||
@@ -2,11 +2,12 @@ import { Sequelize, Transaction } from 'sequelize' | |||
2 | import validator from 'validator' | 2 | import validator from 'validator' |
3 | import { exists } from '@server/helpers/custom-validators/misc' | 3 | import { exists } from '@server/helpers/custom-validators/misc' |
4 | import { WEBSERVER } from '@server/initializers/constants' | 4 | import { WEBSERVER } from '@server/initializers/constants' |
5 | import { buildDirectionAndField, createSafeIn, parseRowCountResult } from '@server/models/utils' | 5 | import { buildSortDirectionAndField } from '@server/models/shared' |
6 | import { MUserAccountId, MUserId } from '@server/types/models' | 6 | import { MUserAccountId, MUserId } from '@server/types/models' |
7 | import { forceNumber } from '@shared/core-utils' | ||
7 | import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' | 8 | import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' |
9 | import { createSafeIn, parseRowCountResult } from '../../../shared' | ||
8 | import { AbstractRunQuery } from '../../../shared/abstract-run-query' | 10 | import { AbstractRunQuery } from '../../../shared/abstract-run-query' |
9 | import { forceNumber } from '@shared/core-utils' | ||
10 | 11 | ||
11 | /** | 12 | /** |
12 | * | 13 | * |
@@ -665,7 +666,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { | |||
665 | } | 666 | } |
666 | 667 | ||
667 | private buildOrder (value: string) { | 668 | private buildOrder (value: string) { |
668 | const { direction, field } = buildDirectionAndField(value) | 669 | const { direction, field } = buildSortDirectionAndField(value) |
669 | if (field.match(/^[a-zA-Z."]+$/) === null) throw new Error('Invalid sort column ' + field) | 670 | if (field.match(/^[a-zA-Z."]+$/) === null) throw new Error('Invalid sort column ' + field) |
670 | 671 | ||
671 | if (field.toLowerCase() === 'random') return 'ORDER BY RANDOM()' | 672 | if (field.toLowerCase() === 'random') return 'ORDER BY RANDOM()' |
diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts index 653b9694b..cebde3755 100644 --- a/server/models/video/tag.ts +++ b/server/models/video/tag.ts | |||
@@ -4,7 +4,7 @@ import { MTag } from '@server/types/models' | |||
4 | import { AttributesOnly } from '@shared/typescript-utils' | 4 | import { AttributesOnly } from '@shared/typescript-utils' |
5 | import { VideoPrivacy, VideoState } from '../../../shared/models/videos' | 5 | import { VideoPrivacy, VideoState } from '../../../shared/models/videos' |
6 | import { isVideoTagValid } from '../../helpers/custom-validators/videos' | 6 | import { isVideoTagValid } from '../../helpers/custom-validators/videos' |
7 | import { throwIfNotValid } from '../utils' | 7 | import { throwIfNotValid } from '../shared' |
8 | import { VideoModel } from './video' | 8 | import { VideoModel } from './video' |
9 | import { VideoTagModel } from './video-tag' | 9 | import { VideoTagModel } from './video-tag' |
10 | 10 | ||
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 1cd8224c0..9247d0e2b 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -5,7 +5,7 @@ import { AttributesOnly } from '@shared/typescript-utils' | |||
5 | import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' | 5 | import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' |
6 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' | 6 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' |
7 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 7 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
8 | import { getBlacklistSort, searchAttribute, SortType, throwIfNotValid } from '../utils' | 8 | import { getBlacklistSort, searchAttribute, throwIfNotValid } from '../shared' |
9 | import { ThumbnailModel } from './thumbnail' | 9 | import { ThumbnailModel } from './thumbnail' |
10 | import { VideoModel } from './video' | 10 | import { VideoModel } from './video' |
11 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' | 11 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' |
@@ -57,7 +57,7 @@ export class VideoBlacklistModel extends Model<Partial<AttributesOnly<VideoBlack | |||
57 | static listForApi (parameters: { | 57 | static listForApi (parameters: { |
58 | start: number | 58 | start: number |
59 | count: number | 59 | count: number |
60 | sort: SortType | 60 | sort: string |
61 | search?: string | 61 | search?: string |
62 | type?: VideoBlacklistType | 62 | type?: VideoBlacklistType |
63 | }) { | 63 | }) { |
@@ -67,7 +67,7 @@ export class VideoBlacklistModel extends Model<Partial<AttributesOnly<VideoBlack | |||
67 | return { | 67 | return { |
68 | offset: start, | 68 | offset: start, |
69 | limit: count, | 69 | limit: count, |
70 | order: getBlacklistSort(sort.sortModel, sort.sortValue) | 70 | order: getBlacklistSort(sort) |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index 5fbcd6e3b..2eaa77407 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts | |||
@@ -23,7 +23,7 @@ import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/vid | |||
23 | import { logger } from '../../helpers/logger' | 23 | import { logger } from '../../helpers/logger' |
24 | import { CONFIG } from '../../initializers/config' | 24 | import { CONFIG } from '../../initializers/config' |
25 | import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' | 25 | import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' |
26 | import { buildWhereIdOrUUID, throwIfNotValid } from '../utils' | 26 | import { buildWhereIdOrUUID, throwIfNotValid } from '../shared' |
27 | import { VideoModel } from './video' | 27 | import { VideoModel } from './video' |
28 | 28 | ||
29 | export enum ScopeNames { | 29 | export enum ScopeNames { |
diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts index 1a1b8c88d..2db4b523a 100644 --- a/server/models/video/video-change-ownership.ts +++ b/server/models/video/video-change-ownership.ts | |||
@@ -3,7 +3,7 @@ import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@se | |||
3 | import { AttributesOnly } from '@shared/typescript-utils' | 3 | import { AttributesOnly } from '@shared/typescript-utils' |
4 | import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos' | 4 | import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos' |
5 | import { AccountModel } from '../account/account' | 5 | import { AccountModel } from '../account/account' |
6 | import { getSort } from '../utils' | 6 | import { getSort } from '../shared' |
7 | import { ScopeNames as VideoScopeNames, VideoModel } from './video' | 7 | import { ScopeNames as VideoScopeNames, VideoModel } from './video' |
8 | 8 | ||
9 | enum ScopeNames { | 9 | enum ScopeNames { |
diff --git a/server/models/video/video-channel-sync.ts b/server/models/video/video-channel-sync.ts index 6e49cde10..a4cbf51f5 100644 --- a/server/models/video/video-channel-sync.ts +++ b/server/models/video/video-channel-sync.ts | |||
@@ -21,7 +21,7 @@ import { VideoChannelSync, VideoChannelSyncState } from '@shared/models' | |||
21 | import { AttributesOnly } from '@shared/typescript-utils' | 21 | import { AttributesOnly } from '@shared/typescript-utils' |
22 | import { AccountModel } from '../account/account' | 22 | import { AccountModel } from '../account/account' |
23 | import { UserModel } from '../user/user' | 23 | import { UserModel } from '../user/user' |
24 | import { getChannelSyncSort, throwIfNotValid } from '../utils' | 24 | import { getChannelSyncSort, throwIfNotValid } from '../shared' |
25 | import { VideoChannelModel } from './video-channel' | 25 | import { VideoChannelModel } from './video-channel' |
26 | 26 | ||
27 | @DefaultScope(() => ({ | 27 | @DefaultScope(() => ({ |
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 132c8f021..b71f5a197 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -43,8 +43,14 @@ import { ActorModel, unusedActorAttributesForAPI } from '../actor/actor' | |||
43 | import { ActorFollowModel } from '../actor/actor-follow' | 43 | import { ActorFollowModel } from '../actor/actor-follow' |
44 | import { ActorImageModel } from '../actor/actor-image' | 44 | import { ActorImageModel } from '../actor/actor-image' |
45 | import { ServerModel } from '../server/server' | 45 | import { ServerModel } from '../server/server' |
46 | import { setAsUpdated } from '../shared' | 46 | import { |
47 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' | 47 | buildServerIdsFollowedBy, |
48 | buildTrigramSearchIndex, | ||
49 | createSimilarityAttribute, | ||
50 | getSort, | ||
51 | setAsUpdated, | ||
52 | throwIfNotValid | ||
53 | } from '../shared' | ||
48 | import { VideoModel } from './video' | 54 | import { VideoModel } from './video' |
49 | import { VideoPlaylistModel } from './video-playlist' | 55 | import { VideoPlaylistModel } from './video-playlist' |
50 | 56 | ||
@@ -831,6 +837,6 @@ export class VideoChannelModel extends Model<Partial<AttributesOnly<VideoChannel | |||
831 | } | 837 | } |
832 | 838 | ||
833 | setAsUpdated (transaction?: Transaction) { | 839 | setAsUpdated (transaction?: Transaction) { |
834 | return setAsUpdated('videoChannel', this.id, transaction) | 840 | return setAsUpdated({ sequelize: this.sequelize, table: 'videoChannel', id: this.id, transaction }) |
835 | } | 841 | } |
836 | } | 842 | } |
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 28a3d723d..ff5142809 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -40,7 +40,7 @@ import { | |||
40 | import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse' | 40 | import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse' |
41 | import { AccountModel } from '../account/account' | 41 | import { AccountModel } from '../account/account' |
42 | import { ActorModel } from '../actor/actor' | 42 | import { ActorModel } from '../actor/actor' |
43 | import { buildLocalAccountIdsIn, buildSQLAttributes, throwIfNotValid } from '../utils' | 43 | import { buildLocalAccountIdsIn, buildSQLAttributes, throwIfNotValid } from '../shared' |
44 | import { ListVideoCommentsOptions, VideoCommentListQueryBuilder } from './sql/comment/video-comment-list-query-builder' | 44 | import { ListVideoCommentsOptions, VideoCommentListQueryBuilder } from './sql/comment/video-comment-list-query-builder' |
45 | import { VideoModel } from './video' | 45 | import { VideoModel } from './video' |
46 | import { VideoChannelModel } from './video-channel' | 46 | import { VideoChannelModel } from './video-channel' |
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 9b42955ef..07bc13de1 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts | |||
@@ -21,6 +21,7 @@ import { | |||
21 | import validator from 'validator' | 21 | import validator from 'validator' |
22 | import { logger } from '@server/helpers/logger' | 22 | import { logger } from '@server/helpers/logger' |
23 | import { extractVideo } from '@server/helpers/video' | 23 | import { extractVideo } from '@server/helpers/video' |
24 | import { CONFIG } from '@server/initializers/config' | ||
24 | import { buildRemoteVideoBaseUrl } from '@server/lib/activitypub/url' | 25 | import { buildRemoteVideoBaseUrl } from '@server/lib/activitypub/url' |
25 | import { | 26 | import { |
26 | getHLSPrivateFileUrl, | 27 | getHLSPrivateFileUrl, |
@@ -50,11 +51,9 @@ import { | |||
50 | } from '../../initializers/constants' | 51 | } from '../../initializers/constants' |
51 | import { MVideoFile, MVideoFileStreamingPlaylistVideo, MVideoFileVideo } from '../../types/models/video/video-file' | 52 | import { MVideoFile, MVideoFileStreamingPlaylistVideo, MVideoFileVideo } from '../../types/models/video/video-file' |
52 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' | 53 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' |
53 | import { doesExist } from '../shared' | 54 | import { doesExist, parseAggregateResult, throwIfNotValid } from '../shared' |
54 | import { parseAggregateResult, throwIfNotValid } from '../utils' | ||
55 | import { VideoModel } from './video' | 55 | import { VideoModel } from './video' |
56 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' | 56 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' |
57 | import { CONFIG } from '@server/initializers/config' | ||
58 | 57 | ||
59 | export enum ScopeNames { | 58 | export enum ScopeNames { |
60 | WITH_VIDEO = 'WITH_VIDEO', | 59 | WITH_VIDEO = 'WITH_VIDEO', |
@@ -266,7 +265,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
266 | static doesInfohashExist (infoHash: string) { | 265 | static doesInfohashExist (infoHash: string) { |
267 | const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1' | 266 | const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1' |
268 | 267 | ||
269 | return doesExist(query, { infoHash }) | 268 | return doesExist(this.sequelize, query, { infoHash }) |
270 | } | 269 | } |
271 | 270 | ||
272 | static async doesVideoExistForVideoFile (id: number, videoIdOrUUID: number | string) { | 271 | static async doesVideoExistForVideoFile (id: number, videoIdOrUUID: number | string) { |
@@ -282,14 +281,14 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
282 | 'LEFT JOIN "video" "hlsVideo" ON "hlsVideo"."id" = "videoStreamingPlaylist"."videoId" AND "hlsVideo"."remote" IS FALSE ' + | 281 | 'LEFT JOIN "video" "hlsVideo" ON "hlsVideo"."id" = "videoStreamingPlaylist"."videoId" AND "hlsVideo"."remote" IS FALSE ' + |
283 | 'WHERE "torrentFilename" = $filename AND ("hlsVideo"."id" IS NOT NULL OR "webtorrent"."id" IS NOT NULL) LIMIT 1' | 282 | 'WHERE "torrentFilename" = $filename AND ("hlsVideo"."id" IS NOT NULL OR "webtorrent"."id" IS NOT NULL) LIMIT 1' |
284 | 283 | ||
285 | return doesExist(query, { filename }) | 284 | return doesExist(this.sequelize, query, { filename }) |
286 | } | 285 | } |
287 | 286 | ||
288 | static async doesOwnedWebTorrentVideoFileExist (filename: string) { | 287 | static async doesOwnedWebTorrentVideoFileExist (filename: string) { |
289 | const query = 'SELECT 1 FROM "videoFile" INNER JOIN "video" ON "video"."id" = "videoFile"."videoId" AND "video"."remote" IS FALSE ' + | 288 | const query = 'SELECT 1 FROM "videoFile" INNER JOIN "video" ON "video"."id" = "videoFile"."videoId" AND "video"."remote" IS FALSE ' + |
290 | `WHERE "filename" = $filename AND "storage" = ${VideoStorage.FILE_SYSTEM} LIMIT 1` | 289 | `WHERE "filename" = $filename AND "storage" = ${VideoStorage.FILE_SYSTEM} LIMIT 1` |
291 | 290 | ||
292 | return doesExist(query, { filename }) | 291 | return doesExist(this.sequelize, query, { filename }) |
293 | } | 292 | } |
294 | 293 | ||
295 | static loadByFilename (filename: string) { | 294 | static loadByFilename (filename: string) { |
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts index da6b92c7a..c040e0fda 100644 --- a/server/models/video/video-import.ts +++ b/server/models/video/video-import.ts | |||
@@ -22,7 +22,7 @@ import { isVideoImportStateValid, isVideoImportTargetUrlValid } from '../../help | |||
22 | import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos' | 22 | import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos' |
23 | import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants' | 23 | import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants' |
24 | import { UserModel } from '../user/user' | 24 | import { UserModel } from '../user/user' |
25 | import { getSort, searchAttribute, throwIfNotValid } from '../utils' | 25 | import { getSort, searchAttribute, throwIfNotValid } from '../shared' |
26 | import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' | 26 | import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' |
27 | import { VideoChannelSyncModel } from './video-channel-sync' | 27 | import { VideoChannelSyncModel } from './video-channel-sync' |
28 | 28 | ||
diff --git a/server/models/video/video-playlist-element.ts b/server/models/video/video-playlist-element.ts index 7181b5599..48f4ed5a9 100644 --- a/server/models/video/video-playlist-element.ts +++ b/server/models/video/video-playlist-element.ts | |||
@@ -31,7 +31,7 @@ import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../shared/ | |||
31 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 31 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
32 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 32 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
33 | import { AccountModel } from '../account/account' | 33 | import { AccountModel } from '../account/account' |
34 | import { getSort, throwIfNotValid } from '../utils' | 34 | import { getSort, throwIfNotValid } from '../shared' |
35 | import { ForAPIOptions, ScopeNames as VideoScopeNames, VideoModel } from './video' | 35 | import { ForAPIOptions, ScopeNames as VideoScopeNames, VideoModel } from './video' |
36 | import { VideoPlaylistModel } from './video-playlist' | 36 | import { VideoPlaylistModel } from './video-playlist' |
37 | 37 | ||
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 8bbe54c49..faf4bea78 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -21,12 +21,8 @@ import { activityPubCollectionPagination } from '@server/lib/activitypub/collect | |||
21 | import { MAccountId, MChannelId } from '@server/types/models' | 21 | import { MAccountId, MChannelId } from '@server/types/models' |
22 | import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils' | 22 | import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils' |
23 | import { buildUUID, uuidToShort } from '@shared/extra-utils' | 23 | import { buildUUID, uuidToShort } from '@shared/extra-utils' |
24 | import { ActivityIconObject, PlaylistObject, VideoPlaylist, VideoPlaylistPrivacy, VideoPlaylistType } from '@shared/models' | ||
24 | import { AttributesOnly } from '@shared/typescript-utils' | 25 | import { AttributesOnly } from '@shared/typescript-utils' |
25 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | ||
26 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' | ||
27 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
28 | import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model' | ||
29 | import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' | ||
30 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 26 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
31 | import { | 27 | import { |
32 | isVideoPlaylistDescriptionValid, | 28 | isVideoPlaylistDescriptionValid, |
@@ -53,7 +49,6 @@ import { | |||
53 | } from '../../types/models/video/video-playlist' | 49 | } from '../../types/models/video/video-playlist' |
54 | import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions } from '../account/account' | 50 | import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions } from '../account/account' |
55 | import { ActorModel } from '../actor/actor' | 51 | import { ActorModel } from '../actor/actor' |
56 | import { setAsUpdated } from '../shared' | ||
57 | import { | 52 | import { |
58 | buildServerIdsFollowedBy, | 53 | buildServerIdsFollowedBy, |
59 | buildTrigramSearchIndex, | 54 | buildTrigramSearchIndex, |
@@ -61,8 +56,9 @@ import { | |||
61 | createSimilarityAttribute, | 56 | createSimilarityAttribute, |
62 | getPlaylistSort, | 57 | getPlaylistSort, |
63 | isOutdated, | 58 | isOutdated, |
59 | setAsUpdated, | ||
64 | throwIfNotValid | 60 | throwIfNotValid |
65 | } from '../utils' | 61 | } from '../shared' |
66 | import { ThumbnailModel } from './thumbnail' | 62 | import { ThumbnailModel } from './thumbnail' |
67 | import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel' | 63 | import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel' |
68 | import { VideoPlaylistElementModel } from './video-playlist-element' | 64 | import { VideoPlaylistElementModel } from './video-playlist-element' |
@@ -641,7 +637,7 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli | |||
641 | } | 637 | } |
642 | 638 | ||
643 | setAsRefreshed () { | 639 | setAsRefreshed () { |
644 | return setAsUpdated('videoPlaylist', this.id) | 640 | return setAsUpdated({ sequelize: this.sequelize, table: 'videoPlaylist', id: this.id }) |
645 | } | 641 | } |
646 | 642 | ||
647 | setVideosLength (videosLength: number) { | 643 | setVideosLength (videosLength: number) { |
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index f2190037e..b4de2b20f 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts | |||
@@ -7,7 +7,7 @@ import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | |||
7 | import { MActorDefault, MActorFollowersUrl, MActorId } from '../../types/models' | 7 | import { MActorDefault, MActorFollowersUrl, MActorId } from '../../types/models' |
8 | import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' | 8 | import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' |
9 | import { ActorModel } from '../actor/actor' | 9 | import { ActorModel } from '../actor/actor' |
10 | import { buildLocalActorIdsIn, throwIfNotValid } from '../utils' | 10 | import { buildLocalActorIdsIn, throwIfNotValid } from '../shared' |
11 | import { VideoModel } from './video' | 11 | import { VideoModel } from './video' |
12 | 12 | ||
13 | enum ScopeNames { | 13 | enum ScopeNames { |
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index 0386edf28..a85c79c9f 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts | |||
@@ -37,8 +37,7 @@ import { | |||
37 | WEBSERVER | 37 | WEBSERVER |
38 | } from '../../initializers/constants' | 38 | } from '../../initializers/constants' |
39 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' | 39 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' |
40 | import { doesExist } from '../shared' | 40 | import { doesExist, throwIfNotValid } from '../shared' |
41 | import { throwIfNotValid } from '../utils' | ||
42 | import { VideoModel } from './video' | 41 | import { VideoModel } from './video' |
43 | 42 | ||
44 | @Table({ | 43 | @Table({ |
@@ -138,7 +137,7 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi | |||
138 | static doesInfohashExist (infoHash: string) { | 137 | static doesInfohashExist (infoHash: string) { |
139 | const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE $infoHash = ANY("p2pMediaLoaderInfohashes") LIMIT 1' | 138 | const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE $infoHash = ANY("p2pMediaLoaderInfohashes") LIMIT 1' |
140 | 139 | ||
141 | return doesExist(query, { infoHash }) | 140 | return doesExist(this.sequelize, query, { infoHash }) |
142 | } | 141 | } |
143 | 142 | ||
144 | static buildP2PMediaLoaderInfoHashes (playlistUrl: string, files: unknown[]) { | 143 | static buildP2PMediaLoaderInfoHashes (playlistUrl: string, files: unknown[]) { |
@@ -237,7 +236,7 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi | |||
237 | `AND "video"."remote" IS FALSE AND "video"."uuid" = $videoUUID ` + | 236 | `AND "video"."remote" IS FALSE AND "video"."uuid" = $videoUUID ` + |
238 | `AND "storage" = ${VideoStorage.FILE_SYSTEM} LIMIT 1` | 237 | `AND "storage" = ${VideoStorage.FILE_SYSTEM} LIMIT 1` |
239 | 238 | ||
240 | return doesExist(query, { videoUUID }) | 239 | return doesExist(this.sequelize, query, { videoUUID }) |
241 | } | 240 | } |
242 | 241 | ||
243 | assignP2PMediaLoaderInfoHashes (video: MVideo, files: unknown[]) { | 242 | assignP2PMediaLoaderInfoHashes (video: MVideo, files: unknown[]) { |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 56cc45cfe..1a10d2da2 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -32,7 +32,7 @@ import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFil | |||
32 | import { VideoPathManager } from '@server/lib/video-path-manager' | 32 | import { VideoPathManager } from '@server/lib/video-path-manager' |
33 | import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' | 33 | import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' |
34 | import { getServerActor } from '@server/models/application/application' | 34 | import { getServerActor } from '@server/models/application/application' |
35 | import { ModelCache } from '@server/models/model-cache' | 35 | import { ModelCache } from '@server/models/shared/model-cache' |
36 | import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' | 36 | import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' |
37 | import { ffprobePromise, getAudioStream, hasAudioStream, uuidToShort } from '@shared/extra-utils' | 37 | import { ffprobePromise, getAudioStream, hasAudioStream, uuidToShort } from '@shared/extra-utils' |
38 | import { | 38 | import { |
@@ -103,10 +103,9 @@ import { VideoRedundancyModel } from '../redundancy/video-redundancy' | |||
103 | import { ServerModel } from '../server/server' | 103 | import { ServerModel } from '../server/server' |
104 | import { TrackerModel } from '../server/tracker' | 104 | import { TrackerModel } from '../server/tracker' |
105 | import { VideoTrackerModel } from '../server/video-tracker' | 105 | import { VideoTrackerModel } from '../server/video-tracker' |
106 | import { setAsUpdated } from '../shared' | 106 | import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, setAsUpdated, throwIfNotValid } from '../shared' |
107 | import { UserModel } from '../user/user' | 107 | import { UserModel } from '../user/user' |
108 | import { UserVideoHistoryModel } from '../user/user-video-history' | 108 | import { UserVideoHistoryModel } from '../user/user-video-history' |
109 | import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils' | ||
110 | import { VideoViewModel } from '../view/video-view' | 109 | import { VideoViewModel } from '../view/video-view' |
111 | import { | 110 | import { |
112 | videoFilesModelToFormattedJSON, | 111 | videoFilesModelToFormattedJSON, |
@@ -1871,7 +1870,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1871 | } | 1870 | } |
1872 | 1871 | ||
1873 | setAsRefreshed (transaction?: Transaction) { | 1872 | setAsRefreshed (transaction?: Transaction) { |
1874 | return setAsUpdated('video', this.id, transaction) | 1873 | return setAsUpdated({ sequelize: this.sequelize, table: 'video', id: this.id, transaction }) |
1875 | } | 1874 | } |
1876 | 1875 | ||
1877 | // --------------------------------------------------------------------------- | 1876 | // --------------------------------------------------------------------------- |