aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel-interface.ts
blob: 21f81e901801c2058d586bb621a1a2f18ee1846d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as Promise from 'bluebird'
import * as Sequelize from 'sequelize'

import { ResultList } from '../../../shared'
import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object'
import { VideoChannel as FormattedVideoChannel } from '../../../shared/models/videos/video-channel.model'
import { AccountInstance } from '../account/account-interface'
import { VideoInstance } from './video-interface'
import { VideoChannelShareInstance } from './video-channel-share-interface'

export namespace VideoChannelMethods {
  export type ToFormattedJSON = (this: VideoChannelInstance) => FormattedVideoChannel
  export type ToActivityPubObject = (this: VideoChannelInstance) => VideoChannelObject
  export type IsOwned = (this: VideoChannelInstance) => boolean

  export type CountByAccount = (accountId: number) => Promise<number>
  export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoChannelInstance> >
  export type LoadByIdAndAccount = (id: number, accountId: number) => Promise<VideoChannelInstance>
  export type ListByAccount = (accountId: number) => Promise< ResultList<VideoChannelInstance> >
  export type LoadAndPopulateAccount = (id: number) => Promise<VideoChannelInstance>
  export type LoadByUUIDAndPopulateAccount = (uuid: string) => Promise<VideoChannelInstance>
  export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
  export type LoadByHostAndUUID = (uuid: string, serverHost: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
  export type LoadAndPopulateAccountAndVideos = (id: number) => Promise<VideoChannelInstance>
  export type LoadByUrl = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
  export type LoadByUUIDOrUrl = (uuid: string, url: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
}

export interface VideoChannelClass {
  countByAccount: VideoChannelMethods.CountByAccount
  listForApi: VideoChannelMethods.ListForApi
  listByAccount: VideoChannelMethods.ListByAccount
  loadByIdAndAccount: VideoChannelMethods.LoadByIdAndAccount
  loadAndPopulateAccount: VideoChannelMethods.LoadAndPopulateAccount
  loadByUUIDAndPopulateAccount: VideoChannelMethods.LoadByUUIDAndPopulateAccount
  loadAndPopulateAccountAndVideos: VideoChannelMethods.LoadAndPopulateAccountAndVideos
  loadByUrl: VideoChannelMethods.LoadByUrl
  loadByUUIDOrUrl: VideoChannelMethods.LoadByUUIDOrUrl
}

export interface VideoChannelAttributes {
  id?: number
  uuid?: string
  name: string
  description: string
  remote: boolean
  url?: string

  Account?: AccountInstance
  Videos?: VideoInstance[]
  VideoChannelShares?: VideoChannelShareInstance[]
}

export interface VideoChannelInstance extends VideoChannelClass, VideoChannelAttributes, Sequelize.Instance<VideoChannelAttributes> {
  id: number
  createdAt: Date
  updatedAt: Date

  isOwned: VideoChannelMethods.IsOwned
  toFormattedJSON: VideoChannelMethods.ToFormattedJSON
  toActivityPubObject: VideoChannelMethods.ToActivityPubObject
}

export interface VideoChannelModel extends VideoChannelClass, Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> {}