]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/account/user-interface.ts
Add ability to list jobs
[github/Chocobozzz/PeerTube.git] / server / models / account / user-interface.ts
CommitLineData
e4f97bab 1import * as Bluebird from 'bluebird'
5cd80545 2import * as Sequelize from 'sequelize'
6fcd19ba 3import { ResultList } from '../../../shared/models/result-list.model'
954605a8
C
4import { UserRight } from '../../../shared/models/users/user-right.enum'
5import { UserRole } from '../../../shared/models/users/user-role'
5cd80545
C
6import { User as FormattedUser } from '../../../shared/models/users/user.model'
7import { AccountInstance } from './account-interface'
e02643f3
C
8
9export namespace UserMethods {
954605a8 10 export type HasRight = (this: UserInstance, right: UserRight) => boolean
6fcd19ba 11 export type IsPasswordMatch = (this: UserInstance, password: string) => Promise<boolean>
69818c93 12
0aef76c4 13 export type ToFormattedJSON = (this: UserInstance) => FormattedUser
b0f9f39e 14 export type IsAbleToUploadVideo = (this: UserInstance, videoFile: Express.Multer.File) => Promise<boolean>
e02643f3 15
e4f97bab 16 export type CountTotal = () => Bluebird<number>
69818c93 17
e4f97bab 18 export type GetByUsername = (username: string) => Bluebird<UserInstance>
69818c93 19
e4f97bab 20 export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<UserInstance> >
69818c93 21
e4f97bab 22 export type LoadById = (id: number) => Bluebird<UserInstance>
69818c93 23
e4f97bab
C
24 export type LoadByUsername = (username: string) => Bluebird<UserInstance>
25 export type LoadByUsernameAndPopulateChannels = (username: string) => Bluebird<UserInstance>
69818c93 26
e4f97bab 27 export type LoadByUsernameOrEmail = (username: string, email: string) => Bluebird<UserInstance>
e02643f3
C
28}
29
30export interface UserClass {
31 isPasswordMatch: UserMethods.IsPasswordMatch,
0aef76c4 32 toFormattedJSON: UserMethods.ToFormattedJSON,
954605a8 33 hasRight: UserMethods.HasRight,
b0f9f39e 34 isAbleToUploadVideo: UserMethods.IsAbleToUploadVideo,
e02643f3
C
35
36 countTotal: UserMethods.CountTotal,
37 getByUsername: UserMethods.GetByUsername,
e02643f3
C
38 listForApi: UserMethods.ListForApi,
39 loadById: UserMethods.LoadById,
40 loadByUsername: UserMethods.LoadByUsername,
72c7248b 41 loadByUsernameAndPopulateChannels: UserMethods.LoadByUsernameAndPopulateChannels,
e02643f3
C
42 loadByUsernameOrEmail: UserMethods.LoadByUsernameOrEmail
43}
44
45export interface UserAttributes {
b0f9f39e 46 id?: number
e02643f3
C
47 password: string
48 username: string
49 email: string
50 displayNSFW?: boolean
ee9e7b61 51 role: UserRole
b0f9f39e 52 videoQuota: number
72c7248b 53
e4f97bab 54 Account?: AccountInstance
e02643f3
C
55}
56
57export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> {
58 id: number
59 createdAt: Date
60 updatedAt: Date
154898b0
C
61
62 isPasswordMatch: UserMethods.IsPasswordMatch
0aef76c4 63 toFormattedJSON: UserMethods.ToFormattedJSON
954605a8 64 hasRight: UserMethods.HasRight
e02643f3
C
65}
66
67export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {}