]>
Commit | Line | Data |
---|---|---|
e4f97bab | 1 | import * as Bluebird from 'bluebird' |
7a7724e6 C |
2 | import * as Sequelize from 'sequelize' |
3 | import { Account as FormattedAccount, ActivityPubActor } from '../../../shared' | |
60862425 | 4 | import { ServerInstance } from '../server/server-interface' |
e4f97bab | 5 | import { VideoChannelInstance } from '../video/video-channel-interface' |
e4f97bab C |
6 | |
7 | export namespace AccountMethods { | |
7a7724e6 C |
8 | export type LoadApplication = () => Bluebird<AccountInstance> |
9 | ||
e4f97bab C |
10 | export type Load = (id: number) => Bluebird<AccountInstance> |
11 | export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance> | |
ce548a10 | 12 | export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> |
60862425 | 13 | export type LoadAccountByServerAndUUID = (uuid: string, serverId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance> |
350e31d6 C |
14 | export type LoadLocalByName = (name: string) => Bluebird<AccountInstance> |
15 | export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance> | |
e4f97bab | 16 | export type ListOwned = () => Bluebird<AccountInstance[]> |
e4f97bab C |
17 | |
18 | export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor | |
7a7724e6 | 19 | export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount |
e4f97bab C |
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 { | |
7a7724e6 | 28 | loadApplication: AccountMethods.LoadApplication |
60862425 | 29 | loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID |
e4f97bab C |
30 | load: AccountMethods.Load |
31 | loadByUUID: AccountMethods.LoadByUUID | |
32 | loadByUrl: AccountMethods.LoadByUrl | |
350e31d6 C |
33 | loadLocalByName: AccountMethods.LoadLocalByName |
34 | loadByNameAndHost: AccountMethods.LoadByNameAndHost | |
e4f97bab | 35 | listOwned: AccountMethods.ListOwned |
e4f97bab C |
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 | ||
60862425 | 53 | serverId?: number |
e4f97bab C |
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 | |
7a7724e6 | 61 | toFormattedJSON: AccountMethods.ToFormattedJSON |
e4f97bab C |
62 | getFollowerSharedInboxUrls: AccountMethods.GetFollowerSharedInboxUrls |
63 | getFollowingUrl: AccountMethods.GetFollowingUrl | |
64 | getFollowersUrl: AccountMethods.GetFollowersUrl | |
65 | getPublicKeyUrl: AccountMethods.GetPublicKeyUrl | |
66 | ||
67 | id: number | |
68 | createdAt: Date | |
69 | updatedAt: Date | |
70 | ||
60862425 | 71 | Server: ServerInstance |
e4f97bab C |
72 | VideoChannels: VideoChannelInstance[] |
73 | } | |
74 | ||
75 | export interface AccountModel extends AccountClass, Sequelize.Model<AccountInstance, AccountAttributes> {} |