aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user-interface.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-09 17:51:58 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commite4f97babf701481b55cc10fb3448feab5f97c867 (patch)
treeaf37402a594dc5ff09f71ecb0687e8cfe4cdb471 /server/models/account/user-interface.ts
parent343ad675f2a26c15b86150a9a3552e619d5d44f4 (diff)
downloadPeerTube-e4f97babf701481b55cc10fb3448feab5f97c867.tar.gz
PeerTube-e4f97babf701481b55cc10fb3448feab5f97c867.tar.zst
PeerTube-e4f97babf701481b55cc10fb3448feab5f97c867.zip
Begin activitypub
Diffstat (limited to 'server/models/account/user-interface.ts')
-rw-r--r--server/models/account/user-interface.ts69
1 files changed, 69 insertions, 0 deletions
diff --git a/server/models/account/user-interface.ts b/server/models/account/user-interface.ts
new file mode 100644
index 000000000..1a04fb750
--- /dev/null
+++ b/server/models/account/user-interface.ts
@@ -0,0 +1,69 @@
1import * as Sequelize from 'sequelize'
2import * as Bluebird from 'bluebird'
3
4// Don't use barrel, import just what we need
5import { AccountInstance } from './account-interface'
6import { User as FormattedUser } from '../../../shared/models/users/user.model'
7import { ResultList } from '../../../shared/models/result-list.model'
8import { UserRight } from '../../../shared/models/users/user-right.enum'
9import { UserRole } from '../../../shared/models/users/user-role'
10
11export namespace UserMethods {
12 export type HasRight = (this: UserInstance, right: UserRight) => boolean
13 export type IsPasswordMatch = (this: UserInstance, password: string) => Promise<boolean>
14
15 export type ToFormattedJSON = (this: UserInstance) => FormattedUser
16 export type IsAbleToUploadVideo = (this: UserInstance, videoFile: Express.Multer.File) => Promise<boolean>
17
18 export type CountTotal = () => Bluebird<number>
19
20 export type GetByUsername = (username: string) => Bluebird<UserInstance>
21
22 export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<UserInstance> >
23
24 export type LoadById = (id: number) => Bluebird<UserInstance>
25
26 export type LoadByUsername = (username: string) => Bluebird<UserInstance>
27 export type LoadByUsernameAndPopulateChannels = (username: string) => Bluebird<UserInstance>
28
29 export type LoadByUsernameOrEmail = (username: string, email: string) => Bluebird<UserInstance>
30}
31
32export interface UserClass {
33 isPasswordMatch: UserMethods.IsPasswordMatch,
34 toFormattedJSON: UserMethods.ToFormattedJSON,
35 hasRight: UserMethods.HasRight,
36 isAbleToUploadVideo: UserMethods.IsAbleToUploadVideo,
37
38 countTotal: UserMethods.CountTotal,
39 getByUsername: UserMethods.GetByUsername,
40 listForApi: UserMethods.ListForApi,
41 loadById: UserMethods.LoadById,
42 loadByUsername: UserMethods.LoadByUsername,
43 loadByUsernameAndPopulateChannels: UserMethods.LoadByUsernameAndPopulateChannels,
44 loadByUsernameOrEmail: UserMethods.LoadByUsernameOrEmail
45}
46
47export interface UserAttributes {
48 id?: number
49 password: string
50 username: string
51 email: string
52 displayNSFW?: boolean
53 role: UserRole
54 videoQuota: number
55
56 Account?: AccountInstance
57}
58
59export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> {
60 id: number
61 createdAt: Date
62 updatedAt: Date
63
64 isPasswordMatch: UserMethods.IsPasswordMatch
65 toFormattedJSON: UserMethods.ToFormattedJSON
66 hasRight: UserMethods.HasRight
67}
68
69export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {}