]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/account/account-interface.ts
Follow works
[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 LoadLocalByName = (name: string) => Bluebird<AccountInstance>
16 export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance>
17 export type ListOwned = () => Bluebird<AccountInstance[]>
18 export type ListAcceptedFollowerUrlsForApi = (id: number, start: number, count?: number) => Promise< ResultList<string> >
19 export type ListAcceptedFollowingUrlsForApi = (id: number, start: number, count?: number) => Promise< ResultList<string> >
20 export type ListFollowingForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountInstance> >
21 export type ListFollowersForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountInstance> >
22
23 export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor
24 export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount
25 export type IsOwned = (this: AccountInstance) => boolean
26 export type GetFollowerSharedInboxUrls = (this: AccountInstance) => Bluebird<string[]>
27 export type GetFollowingUrl = (this: AccountInstance) => string
28 export type GetFollowersUrl = (this: AccountInstance) => string
29 export type GetPublicKeyUrl = (this: AccountInstance) => string
30 }
31
32 export interface AccountClass {
33 loadApplication: AccountMethods.LoadApplication
34 loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID
35 load: AccountMethods.Load
36 loadByUUID: AccountMethods.LoadByUUID
37 loadByUrl: AccountMethods.LoadByUrl
38 loadLocalByName: AccountMethods.LoadLocalByName
39 loadByNameAndHost: AccountMethods.LoadByNameAndHost
40 listOwned: AccountMethods.ListOwned
41 listAcceptedFollowerUrlsForApi: AccountMethods.ListAcceptedFollowerUrlsForApi
42 listAcceptedFollowingUrlsForApi: AccountMethods.ListAcceptedFollowingUrlsForApi
43 listFollowingForApi: AccountMethods.ListFollowingForApi
44 listFollowersForApi: AccountMethods.ListFollowersForApi
45 }
46
47 export interface AccountAttributes {
48 name: string
49 url: string
50 publicKey: string
51 privateKey: string
52 followersCount: number
53 followingCount: number
54 inboxUrl: string
55 outboxUrl: string
56 sharedInboxUrl: string
57 followersUrl: string
58 followingUrl: string
59
60 uuid?: string
61
62 podId?: number
63 userId?: number
64 applicationId?: number
65 }
66
67 export interface AccountInstance extends AccountClass, AccountAttributes, Sequelize.Instance<AccountAttributes> {
68 isOwned: AccountMethods.IsOwned
69 toActivityPubObject: AccountMethods.ToActivityPubObject
70 toFormattedJSON: AccountMethods.ToFormattedJSON
71 getFollowerSharedInboxUrls: AccountMethods.GetFollowerSharedInboxUrls
72 getFollowingUrl: AccountMethods.GetFollowingUrl
73 getFollowersUrl: AccountMethods.GetFollowersUrl
74 getPublicKeyUrl: AccountMethods.GetPublicKeyUrl
75
76 id: number
77 createdAt: Date
78 updatedAt: Date
79
80 Pod: PodInstance
81 VideoChannels: VideoChannelInstance[]
82 }
83
84 export interface AccountModel extends AccountClass, Sequelize.Model<AccountInstance, AccountAttributes> {}