Remove references to author
[oweals/peertube.git] / server / models / account / account-interface.ts
1 import * as Sequelize from 'sequelize'
2 import * as Bluebird from 'bluebird'
3
4 import { PodInstance } from '../pod/pod-interface'
5 import { VideoChannelInstance } from '../video/video-channel-interface'
6 import { ActivityPubActor } from '../../../shared'
7 import { ResultList } from '../../../shared/models/result-list.model'
8
9 export namespace AccountMethods {
10   export type Load = (id: number) => Bluebird<AccountInstance>
11   export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance>
12   export type LoadByUrl = (url: string) => Bluebird<AccountInstance>
13   export type LoadAccountByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance>
14   export type LoadLocalAccountByName = (name: string) => Bluebird<AccountInstance>
15   export type ListOwned = () => Bluebird<AccountInstance[]>
16   export type ListFollowerUrlsForApi = (name: string, start: number, count: number) => Promise< ResultList<string> >
17   export type ListFollowingUrlsForApi = (name: string, start: number, count: number) => Promise< ResultList<string> >
18
19   export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor
20   export type IsOwned = (this: AccountInstance) => boolean
21   export type GetFollowerSharedInboxUrls = (this: AccountInstance) => Bluebird<string[]>
22   export type GetFollowingUrl = (this: AccountInstance) => string
23   export type GetFollowersUrl = (this: AccountInstance) => string
24   export type GetPublicKeyUrl = (this: AccountInstance) => string
25 }
26
27 export interface AccountClass {
28   loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID
29   load: AccountMethods.Load
30   loadByUUID: AccountMethods.LoadByUUID
31   loadByUrl: AccountMethods.LoadByUrl
32   loadLocalAccountByName: AccountMethods.LoadLocalAccountByName
33   listOwned: AccountMethods.ListOwned
34   listFollowerUrlsForApi: AccountMethods.ListFollowerUrlsForApi
35   listFollowingUrlsForApi: AccountMethods.ListFollowingUrlsForApi
36 }
37
38 export interface AccountAttributes {
39   name: string
40   url: string
41   publicKey: string
42   privateKey: string
43   followersCount: number
44   followingCount: number
45   inboxUrl: string
46   outboxUrl: string
47   sharedInboxUrl: string
48   followersUrl: string
49   followingUrl: string
50
51   uuid?: string
52
53   podId?: number
54   userId?: number
55   applicationId?: number
56 }
57
58 export interface AccountInstance extends AccountClass, AccountAttributes, Sequelize.Instance<AccountAttributes> {
59   isOwned: AccountMethods.IsOwned
60   toActivityPubObject: AccountMethods.ToActivityPubObject
61   getFollowerSharedInboxUrls: AccountMethods.GetFollowerSharedInboxUrls
62   getFollowingUrl: AccountMethods.GetFollowingUrl
63   getFollowersUrl: AccountMethods.GetFollowersUrl
64   getPublicKeyUrl: AccountMethods.GetPublicKeyUrl
65
66   id: number
67   createdAt: Date
68   updatedAt: Date
69
70   Pod: PodInstance
71   VideoChannels: VideoChannelInstance[]
72 }
73
74 export interface AccountModel extends AccountClass, Sequelize.Model<AccountInstance, AccountAttributes> {}