]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/author-interface.ts
Fix integrity issues with after destroy hook
[github/Chocobozzz/PeerTube.git] / server / models / video / author-interface.ts
index c1b30848ca9c44111f957249470a944b3cd3d787..fc69ff3c2b06b6d51c1979dca090b2bbfb87204c 100644 (file)
@@ -1,27 +1,45 @@
 import * as Sequelize from 'sequelize'
+import * as Promise from 'bluebird'
 
-import { PodInstance } from '../pod'
+import { PodInstance } from '../pod/pod-interface'
+import { RemoteVideoAuthorCreateData } from '../../../shared/models/pods/remote-video/remote-video-author-create-request.model'
+import { VideoChannelInstance } from './video-channel-interface'
 
 export namespace AuthorMethods {
-  export type FindOrCreateAuthorCallback = (err: Error, authorInstance?: AuthorInstance) => void
-  export type FindOrCreateAuthor = (name: string, podId: number, userId: number, transaction: Sequelize.Transaction, callback: FindOrCreateAuthorCallback) => void
+  export type Load = (id: number) => Promise<AuthorInstance>
+  export type LoadByUUID = (uuid: string) => Promise<AuthorInstance>
+  export type LoadAuthorByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Promise<AuthorInstance>
+  export type ListOwned = () => Promise<AuthorInstance[]>
+
+  export type ToAddRemoteJSON = (this: AuthorInstance) => RemoteVideoAuthorCreateData
+  export type IsOwned = (this: AuthorInstance) => boolean
 }
 
 export interface AuthorClass {
-  findOrCreateAuthor: AuthorMethods.FindOrCreateAuthor
+  loadAuthorByPodAndUUID: AuthorMethods.LoadAuthorByPodAndUUID
+  load: AuthorMethods.Load
+  loadByUUID: AuthorMethods.LoadByUUID
+  listOwned: AuthorMethods.ListOwned
 }
 
 export interface AuthorAttributes {
   name: string
+  uuid?: string
+
+  podId?: number
+  userId?: number
 }
 
 export interface AuthorInstance extends AuthorClass, AuthorAttributes, Sequelize.Instance<AuthorAttributes> {
+  isOwned: AuthorMethods.IsOwned
+  toAddRemoteJSON: AuthorMethods.ToAddRemoteJSON
+
   id: number
   createdAt: Date
   updatedAt: Date
 
-  podId: number
   Pod: PodInstance
+  VideoChannels: VideoChannelInstance[]
 }
 
 export interface AuthorModel extends AuthorClass, Sequelize.Model<AuthorInstance, AuthorAttributes> {}