2017-11-09 17:51:58 +01:00
|
|
|
import * as Bluebird from 'bluebird'
|
2017-11-13 17:39:41 +01:00
|
|
|
import * as Sequelize from 'sequelize'
|
|
|
|
import { Account as FormattedAccount, ActivityPubActor } from '../../../shared'
|
|
|
|
import { ResultList } from '../../../shared/models/result-list.model'
|
2017-11-09 17:51:58 +01:00
|
|
|
import { PodInstance } from '../pod/pod-interface'
|
|
|
|
import { VideoChannelInstance } from '../video/video-channel-interface'
|
|
|
|
|
|
|
|
export namespace AccountMethods {
|
2017-11-13 17:39:41 +01:00
|
|
|
export type LoadApplication = () => Bluebird<AccountInstance>
|
|
|
|
|
2017-11-09 17:51:58 +01:00
|
|
|
export type Load = (id: number) => Bluebird<AccountInstance>
|
|
|
|
export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance>
|
2017-11-13 18:48:28 +01:00
|
|
|
export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance>
|
2017-11-09 17:51:58 +01:00
|
|
|
export type LoadAccountByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance>
|
2017-11-13 17:39:41 +01:00
|
|
|
export type LoadLocalAccountByNameAndPod = (name: string, host: string) => Bluebird<AccountInstance>
|
2017-11-09 17:51:58 +01:00
|
|
|
export type ListOwned = () => Bluebird<AccountInstance[]>
|
2017-11-13 17:39:41 +01:00
|
|
|
export type ListFollowerUrlsForApi = (id: number, start: number, count?: number) => Promise< ResultList<string> >
|
|
|
|
export type ListFollowingUrlsForApi = (id: number, start: number, count?: number) => Promise< ResultList<string> >
|
|
|
|
export type ListFollowingForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountInstance> >
|
|
|
|
export type ListFollowersForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountInstance> >
|
2017-11-09 17:51:58 +01:00
|
|
|
|
|
|
|
export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor
|
2017-11-13 17:39:41 +01:00
|
|
|
export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount
|
2017-11-09 17:51:58 +01:00
|
|
|
export type IsOwned = (this: AccountInstance) => boolean
|
|
|
|
export type GetFollowerSharedInboxUrls = (this: AccountInstance) => Bluebird<string[]>
|
|
|
|
export type GetFollowingUrl = (this: AccountInstance) => string
|
|
|
|
export type GetFollowersUrl = (this: AccountInstance) => string
|
|
|
|
export type GetPublicKeyUrl = (this: AccountInstance) => string
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AccountClass {
|
2017-11-13 17:39:41 +01:00
|
|
|
loadApplication: AccountMethods.LoadApplication
|
2017-11-09 17:51:58 +01:00
|
|
|
loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID
|
|
|
|
load: AccountMethods.Load
|
|
|
|
loadByUUID: AccountMethods.LoadByUUID
|
|
|
|
loadByUrl: AccountMethods.LoadByUrl
|
2017-11-13 17:39:41 +01:00
|
|
|
loadLocalAccountByNameAndPod: AccountMethods.LoadLocalAccountByNameAndPod
|
2017-11-09 17:51:58 +01:00
|
|
|
listOwned: AccountMethods.ListOwned
|
|
|
|
listFollowerUrlsForApi: AccountMethods.ListFollowerUrlsForApi
|
|
|
|
listFollowingUrlsForApi: AccountMethods.ListFollowingUrlsForApi
|
2017-11-13 17:39:41 +01:00
|
|
|
listFollowingForApi: AccountMethods.ListFollowingForApi
|
|
|
|
listFollowersForApi: AccountMethods.ListFollowersForApi
|
2017-11-09 17:51:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface AccountAttributes {
|
|
|
|
name: string
|
|
|
|
url: string
|
|
|
|
publicKey: string
|
|
|
|
privateKey: string
|
|
|
|
followersCount: number
|
|
|
|
followingCount: number
|
|
|
|
inboxUrl: string
|
|
|
|
outboxUrl: string
|
|
|
|
sharedInboxUrl: string
|
|
|
|
followersUrl: string
|
|
|
|
followingUrl: string
|
|
|
|
|
|
|
|
uuid?: string
|
|
|
|
|
|
|
|
podId?: number
|
|
|
|
userId?: number
|
|
|
|
applicationId?: number
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AccountInstance extends AccountClass, AccountAttributes, Sequelize.Instance<AccountAttributes> {
|
|
|
|
isOwned: AccountMethods.IsOwned
|
|
|
|
toActivityPubObject: AccountMethods.ToActivityPubObject
|
2017-11-13 17:39:41 +01:00
|
|
|
toFormattedJSON: AccountMethods.ToFormattedJSON
|
2017-11-09 17:51:58 +01:00
|
|
|
getFollowerSharedInboxUrls: AccountMethods.GetFollowerSharedInboxUrls
|
|
|
|
getFollowingUrl: AccountMethods.GetFollowingUrl
|
|
|
|
getFollowersUrl: AccountMethods.GetFollowersUrl
|
|
|
|
getPublicKeyUrl: AccountMethods.GetPublicKeyUrl
|
|
|
|
|
|
|
|
id: number
|
|
|
|
createdAt: Date
|
|
|
|
updatedAt: Date
|
|
|
|
|
|
|
|
Pod: PodInstance
|
|
|
|
VideoChannels: VideoChannelInstance[]
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AccountModel extends AccountClass, Sequelize.Model<AccountInstance, AccountAttributes> {}
|