]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/video/video-channel-interface.ts
Begin activitypub
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel-interface.ts
1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
3
4 import { ResultList } from '../../../shared'
5
6 // Don't use barrel, import just what we need
7 import { VideoChannel as FormattedVideoChannel } from '../../../shared/models/videos/video-channel.model'
8 import { VideoInstance } from './video-interface'
9 import { AccountInstance } from '../account/account-interface'
10 import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object'
11
12 export namespace VideoChannelMethods {
13 export type ToFormattedJSON = (this: VideoChannelInstance) => FormattedVideoChannel
14 export type ToActivityPubObject = (this: VideoChannelInstance) => VideoChannelObject
15 export type IsOwned = (this: VideoChannelInstance) => boolean
16
17 export type CountByAccount = (accountId: number) => Promise<number>
18 export type ListOwned = () => Promise<VideoChannelInstance[]>
19 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoChannelInstance> >
20 export type LoadByIdAndAccount = (id: number, accountId: number) => Promise<VideoChannelInstance>
21 export type ListByAccount = (accountId: number) => Promise< ResultList<VideoChannelInstance> >
22 export type LoadAndPopulateAccount = (id: number) => Promise<VideoChannelInstance>
23 export type LoadByUUIDAndPopulateAccount = (uuid: string) => Promise<VideoChannelInstance>
24 export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
25 export type LoadByHostAndUUID = (uuid: string, podHost: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
26 export type LoadAndPopulateAccountAndVideos = (id: number) => Promise<VideoChannelInstance>
27 }
28
29 export interface VideoChannelClass {
30 countByAccount: VideoChannelMethods.CountByAccount
31 listForApi: VideoChannelMethods.ListForApi
32 listByAccount: VideoChannelMethods.ListByAccount
33 listOwned: VideoChannelMethods.ListOwned
34 loadByIdAndAccount: VideoChannelMethods.LoadByIdAndAccount
35 loadByUUID: VideoChannelMethods.LoadByUUID
36 loadByHostAndUUID: VideoChannelMethods.LoadByHostAndUUID
37 loadAndPopulateAccount: VideoChannelMethods.LoadAndPopulateAccount
38 loadByUUIDAndPopulateAccount: VideoChannelMethods.LoadByUUIDAndPopulateAccount
39 loadAndPopulateAccountAndVideos: VideoChannelMethods.LoadAndPopulateAccountAndVideos
40 }
41
42 export interface VideoChannelAttributes {
43 id?: number
44 uuid?: string
45 name: string
46 description: string
47 remote: boolean
48 url: string
49
50 Account?: AccountInstance
51 Videos?: VideoInstance[]
52 }
53
54 export interface VideoChannelInstance extends VideoChannelClass, VideoChannelAttributes, Sequelize.Instance<VideoChannelAttributes> {
55 id: number
56 createdAt: Date
57 updatedAt: Date
58
59 isOwned: VideoChannelMethods.IsOwned
60 toFormattedJSON: VideoChannelMethods.ToFormattedJSON
61 toActivityPubObject: VideoChannelMethods.ToActivityPubObject
62 }
63
64 export interface VideoChannelModel extends VideoChannelClass, Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> {}