diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/user/user.ts | 9 | ||||
-rw-r--r-- | server/models/video/video-job-info.ts | 6 | ||||
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 24 |
3 files changed, 25 insertions, 14 deletions
diff --git a/server/models/user/user.ts b/server/models/user/user.ts index 1a7c84390..34329580b 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts | |||
@@ -403,6 +403,11 @@ export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> { | |||
403 | @Column | 403 | @Column |
404 | lastLoginDate: Date | 404 | lastLoginDate: Date |
405 | 405 | ||
406 | @AllowNull(true) | ||
407 | @Default(null) | ||
408 | @Column | ||
409 | otpSecret: string | ||
410 | |||
406 | @CreatedAt | 411 | @CreatedAt |
407 | createdAt: Date | 412 | createdAt: Date |
408 | 413 | ||
@@ -935,7 +940,9 @@ export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> { | |||
935 | 940 | ||
936 | pluginAuth: this.pluginAuth, | 941 | pluginAuth: this.pluginAuth, |
937 | 942 | ||
938 | lastLoginDate: this.lastLoginDate | 943 | lastLoginDate: this.lastLoginDate, |
944 | |||
945 | twoFactorEnabled: !!this.otpSecret | ||
939 | } | 946 | } |
940 | 947 | ||
941 | if (parameters.withAdminFlags) { | 948 | if (parameters.withAdminFlags) { |
diff --git a/server/models/video/video-job-info.ts b/server/models/video/video-job-info.ts index 7497addf1..740f6b5c6 100644 --- a/server/models/video/video-job-info.ts +++ b/server/models/video/video-job-info.ts | |||
@@ -84,7 +84,7 @@ export class VideoJobInfoModel extends Model<Partial<AttributesOnly<VideoJobInfo | |||
84 | static async decrease (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> { | 84 | static async decrease (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> { |
85 | const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } } | 85 | const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } } |
86 | 86 | ||
87 | const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(` | 87 | const result = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(` |
88 | UPDATE | 88 | UPDATE |
89 | "videoJobInfo" | 89 | "videoJobInfo" |
90 | SET | 90 | SET |
@@ -97,7 +97,9 @@ export class VideoJobInfoModel extends Model<Partial<AttributesOnly<VideoJobInfo | |||
97 | "${column}"; | 97 | "${column}"; |
98 | `, options) | 98 | `, options) |
99 | 99 | ||
100 | return pendingMove | 100 | if (result.length === 0) return undefined |
101 | |||
102 | return result[0].pendingMove | ||
101 | } | 103 | } |
102 | 104 | ||
103 | static async abortAllTasks (videoUUID: string, column: VideoJobInfoColumnType): Promise<void> { | 105 | static async abortAllTasks (videoUUID: string, column: VideoJobInfoColumnType): Promise<void> { |
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index f587989dc..2b6771f27 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts | |||
@@ -245,21 +245,25 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi | |||
245 | } | 245 | } |
246 | 246 | ||
247 | getMasterPlaylistUrl (video: MVideo) { | 247 | getMasterPlaylistUrl (video: MVideo) { |
248 | if (this.storage === VideoStorage.OBJECT_STORAGE) { | 248 | if (video.isOwned()) { |
249 | return getHLSPublicFileUrl(this.playlistUrl) | 249 | if (this.storage === VideoStorage.OBJECT_STORAGE) { |
250 | } | 250 | return getHLSPublicFileUrl(this.playlistUrl) |
251 | } | ||
251 | 252 | ||
252 | if (video.isOwned()) return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video.uuid) | 253 | return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video.uuid) |
254 | } | ||
253 | 255 | ||
254 | return this.playlistUrl | 256 | return this.playlistUrl |
255 | } | 257 | } |
256 | 258 | ||
257 | getSha256SegmentsUrl (video: MVideo) { | 259 | getSha256SegmentsUrl (video: MVideo) { |
258 | if (this.storage === VideoStorage.OBJECT_STORAGE) { | 260 | if (video.isOwned()) { |
259 | return getHLSPublicFileUrl(this.segmentsSha256Url) | 261 | if (this.storage === VideoStorage.OBJECT_STORAGE) { |
260 | } | 262 | return getHLSPublicFileUrl(this.segmentsSha256Url) |
263 | } | ||
261 | 264 | ||
262 | if (video.isOwned()) return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video.uuid, video.isLive) | 265 | return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video.uuid) |
266 | } | ||
263 | 267 | ||
264 | return this.segmentsSha256Url | 268 | return this.segmentsSha256Url |
265 | } | 269 | } |
@@ -287,9 +291,7 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi | |||
287 | return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.playlistFilename) | 291 | return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.playlistFilename) |
288 | } | 292 | } |
289 | 293 | ||
290 | private getSha256SegmentsStaticPath (videoUUID: string, isLive: boolean) { | 294 | private getSha256SegmentsStaticPath (videoUUID: string) { |
291 | if (isLive) return join('/live', 'segments-sha256', videoUUID) | ||
292 | |||
293 | return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.segmentsSha256Filename) | 295 | return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.segmentsSha256Filename) |
294 | } | 296 | } |
295 | } | 297 | } |