]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-streaming-playlist.ts
Fix createdAt/updatedAt issues
[github/Chocobozzz/PeerTube.git] / server / models / video / video-streaming-playlist.ts
index e50b5d1068b51a52d8cd2d8b1c6455b1d0fae00b..31dc82c541109ed56a72078928e9e9aae4b9e2f6 100644 (file)
@@ -1,8 +1,7 @@
-import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
+import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, HasMany, Is, Model, Table, UpdatedAt, DataType } from 'sequelize-typescript'
 import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
 import { throwIfNotValid } from '../utils'
 import { VideoModel } from './video'
-import * as Sequelize from 'sequelize'
 import { VideoRedundancyModel } from '../redundancy/video-redundancy'
 import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
 import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
@@ -11,6 +10,7 @@ import { VideoFileModel } from './video-file'
 import { join } from 'path'
 import { sha1 } from '../../helpers/core-utils'
 import { isArrayOf } from '../../helpers/custom-validators/misc'
+import { QueryTypes, Op } from 'sequelize'
 
 @Table({
   tableName: 'videoStreamingPlaylist',
@@ -82,15 +82,13 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod
   static doesInfohashExist (infoHash: string) {
     const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE $infoHash = ANY("p2pMediaLoaderInfohashes") LIMIT 1'
     const options = {
-      type: Sequelize.QueryTypes.SELECT,
+      type: QueryTypes.SELECT as QueryTypes.SELECT,
       bind: { infoHash },
       raw: true
     }
 
-    return VideoModel.sequelize.query(query, options)
-              .then(results => {
-                return results.length === 1
-              })
+    return VideoModel.sequelize.query<object>(query, options)
+              .then(results => results.length === 1)
   }
 
   static buildP2PMediaLoaderInfoHashes (playlistUrl: string, videoFiles: VideoFileModel[]) {
@@ -108,7 +106,7 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod
     const query = {
       where: {
         p2pMediaLoaderPeerVersion: {
-          [Sequelize.Op.ne]: P2P_MEDIA_LOADER_PEER_VERSION
+          [Op.ne]: P2P_MEDIA_LOADER_PEER_VERSION
         }
       }
     }