Fetch video likes/dislikes too
[oweals/peertube.git] / server / models / account / account-follow-interface.ts
1 import * as Bluebird from 'bluebird'
2 import * as Sequelize from 'sequelize'
3 import { AccountFollow, FollowState } from '../../../shared/models/accounts/follow.model'
4 import { ResultList } from '../../../shared/models/result-list.model'
5 import { AccountInstance } from './account-interface'
6
7 export namespace AccountFollowMethods {
8   export type LoadByAccountAndTarget = (
9     accountId: number,
10     targetAccountId: number,
11     t?: Sequelize.Transaction
12   ) => Bluebird<AccountFollowInstance>
13
14   export type ListFollowingForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountFollowInstance>>
15   export type ListFollowersForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountFollowInstance>>
16
17   export type ListAcceptedFollowerUrlsForApi = (accountId: number[], start?: number, count?: number) => Promise< ResultList<string> >
18   export type ListAcceptedFollowingUrlsForApi = (accountId: number[], start?: number, count?: number) => Promise< ResultList<string> >
19   export type ListAcceptedFollowerSharedInboxUrls = (accountId: number[]) => Promise< ResultList<string> >
20   export type ToFormattedJSON = (this: AccountFollowInstance) => AccountFollow
21 }
22
23 export interface AccountFollowClass {
24   loadByAccountAndTarget: AccountFollowMethods.LoadByAccountAndTarget
25   listFollowersForApi: AccountFollowMethods.ListFollowersForApi
26   listFollowingForApi: AccountFollowMethods.ListFollowingForApi
27
28   listAcceptedFollowerUrlsForApi: AccountFollowMethods.ListAcceptedFollowerUrlsForApi
29   listAcceptedFollowingUrlsForApi: AccountFollowMethods.ListAcceptedFollowingUrlsForApi
30   listAcceptedFollowerSharedInboxUrls: AccountFollowMethods.ListAcceptedFollowerSharedInboxUrls
31 }
32
33 export interface AccountFollowAttributes {
34   accountId: number
35   targetAccountId: number
36   state: FollowState
37 }
38
39 export interface AccountFollowInstance extends AccountFollowClass, AccountFollowAttributes, Sequelize.Instance<AccountFollowAttributes> {
40   id: number
41   createdAt: Date
42   updatedAt: Date
43
44   AccountFollower?: AccountInstance
45   AccountFollowing?: AccountInstance
46
47   toFormattedJSON: AccountFollowMethods.ToFormattedJSON
48 }
49
50 export interface AccountFollowModel extends AccountFollowClass, Sequelize.Model<AccountFollowInstance, AccountFollowAttributes> {}