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