]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-interface.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / server / models / video / video-interface.ts
index 587652f45f493966fb3870f1c1c84344a3c88c4e..9f29c842cc972a807b6fb0348a06c00ec1f5bc69 100644 (file)
@@ -1,18 +1,12 @@
+import * as Bluebird from 'bluebird'
 import * as Sequelize from 'sequelize'
-import * as Promise from 'bluebird'
+import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
+import { ResultList } from '../../../shared/models/result-list.model'
+import { Video as FormattedVideo, VideoDetails as FormattedDetailsVideo } from '../../../shared/models/videos/video.model'
 
 import { TagAttributes, TagInstance } from './tag-interface'
-import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
-
-// Don't use barrel, import just what we need
-import {
-  Video as FormattedVideo,
-  VideoDetails as FormattedDetailsVideo
-} from '../../../shared/models/videos/video.model'
-import { RemoteVideoUpdateData } from '../../../shared/models/pods/remote-video/remote-video-update-request.model'
-import { RemoteVideoCreateData } from '../../../shared/models/pods/remote-video/remote-video-create-request.model'
-import { ResultList } from '../../../shared/models/result-list.model'
 import { VideoChannelInstance } from './video-channel-interface'
+import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
 
 export namespace VideoMethods {
   export type GetThumbnailName = (this: VideoInstance) => string
@@ -29,8 +23,7 @@ export namespace VideoMethods {
   export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
   export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
 
-  export type ToAddRemoteJSON = (this: VideoInstance) => Promise<RemoteVideoCreateData>
-  export type ToUpdateRemoteJSON = (this: VideoInstance) => RemoteVideoUpdateData
+  export type ToActivityPubObject = (this: VideoInstance) => VideoTorrentObject
 
   export type OptimizeOriginalVideofile = (this: VideoInstance) => Promise<void>
   export type TranscodeOriginalVideofile = (this: VideoInstance, resolution: number) => Promise<void>
@@ -40,30 +33,36 @@ export namespace VideoMethods {
   export type GetPreviewPath = (this: VideoInstance) => string
   export type GetDescriptionPath = (this: VideoInstance) => string
   export type GetTruncatedDescription = (this: VideoInstance) => string
+  export type GetCategoryLabel = (this: VideoInstance) => string
+  export type GetLicenceLabel = (this: VideoInstance) => string
+  export type GetLanguageLabel = (this: VideoInstance) => string
 
   // Return thumbnail name
   export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string>
 
-  export type List = () => Promise<VideoInstance[]>
-  export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]>
-  export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]>
+  export type List = () => Bluebird<VideoInstance[]>
+  export type ListOwnedAndPopulateAccountAndTags = () => Bluebird<VideoInstance[]>
+  export type ListOwnedByAccount = (account: string) => Bluebird<VideoInstance[]>
 
-  export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> >
-  export type SearchAndPopulateAuthorAndPodAndTags = (
+  export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
+  export type ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
+  export type SearchAndPopulateAccountAndServerAndTags = (
     value: string,
     field: string,
     start: number,
     count: number,
     sort: string
-  ) => Promise< ResultList<VideoInstance> >
-
-  export type Load = (id: number) => Promise<VideoInstance>
-  export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance>
-  export type LoadLocalVideoByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance>
-  export type LoadByHostAndUUID = (fromHost: string, uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance>
-  export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance>
-  export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance>
-  export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance>
+  ) => Bluebird< ResultList<VideoInstance> >
+
+  export type Load = (id: number) => Bluebird<VideoInstance>
+  export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
+  export type LoadByUrlAndPopulateAccount = (url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
+  export type LoadLocalVideoByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
+  export type LoadByHostAndUUID = (fromHost: string, uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
+  export type LoadAndPopulateAccount = (id: number) => Bluebird<VideoInstance>
+  export type LoadAndPopulateAccountAndServerAndTags = (id: number) => Bluebird<VideoInstance>
+  export type LoadByUUIDAndPopulateAccountAndServerAndTags = (uuid: string) => Bluebird<VideoInstance>
+  export type LoadByUUIDOrURL = (uuid: string, url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
 
   export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
   export type RemovePreview = (this: VideoInstance) => Promise<void>
@@ -75,16 +74,19 @@ export interface VideoClass {
   generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
   list: VideoMethods.List
   listForApi: VideoMethods.ListForApi
-  listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
-  listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
+  listUserVideosForApi: VideoMethods.ListUserVideosForApi
+  listOwnedAndPopulateAccountAndTags: VideoMethods.ListOwnedAndPopulateAccountAndTags
+  listOwnedByAccount: VideoMethods.ListOwnedByAccount
   load: VideoMethods.Load
-  loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
-  loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
+  loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount
+  loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags
   loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
   loadByUUID: VideoMethods.LoadByUUID
+  loadByUrlAndPopulateAccount: VideoMethods.LoadByUrlAndPopulateAccount
+  loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL
   loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID
-  loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
-  searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
+  loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags
+  searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags
 }
 
 export interface VideoAttributes {
@@ -97,11 +99,17 @@ export interface VideoAttributes {
   nsfw: boolean
   description: string
   duration: number
+  privacy: number
   views?: number
   likes?: number
   dislikes?: number
   remote: boolean
+  url?: string
 
+  createdAt?: Date
+  updatedAt?: Date
+
+  parentId?: number
   channelId?: number
 
   VideoChannel?: VideoChannelInstance
@@ -110,9 +118,6 @@ export interface VideoAttributes {
 }
 
 export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
-  createdAt: Date
-  updatedAt: Date
-
   createPreview: VideoMethods.CreatePreview
   createThumbnail: VideoMethods.CreateThumbnail
   createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash
@@ -129,16 +134,18 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In
   removePreview: VideoMethods.RemovePreview
   removeThumbnail: VideoMethods.RemoveThumbnail
   removeTorrent: VideoMethods.RemoveTorrent
-  toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
+  toActivityPubObject: VideoMethods.ToActivityPubObject
   toFormattedJSON: VideoMethods.ToFormattedJSON
   toFormattedDetailsJSON: VideoMethods.ToFormattedDetailsJSON
-  toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
   optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile
   transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile
   getOriginalFileHeight: VideoMethods.GetOriginalFileHeight
   getEmbedPath: VideoMethods.GetEmbedPath
   getDescriptionPath: VideoMethods.GetDescriptionPath
   getTruncatedDescription: VideoMethods.GetTruncatedDescription
+  getCategoryLabel: VideoMethods.GetCategoryLabel
+  getLicenceLabel: VideoMethods.GetLicenceLabel
+  getLanguageLabel: VideoMethods.GetLanguageLabel
 
   setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
   addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string>