diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-09 17:51:58 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | e4f97babf701481b55cc10fb3448feab5f97c867 (patch) | |
tree | af37402a594dc5ff09f71ecb0687e8cfe4cdb471 /server/models/account/user-interface.ts | |
parent | 343ad675f2a26c15b86150a9a3552e619d5d44f4 (diff) | |
download | PeerTube-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.ts | 69 |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import * as Bluebird from 'bluebird' | ||
3 | |||
4 | // Don't use barrel, import just what we need | ||
5 | import { AccountInstance } from './account-interface' | ||
6 | import { User as FormattedUser } from '../../../shared/models/users/user.model' | ||
7 | import { ResultList } from '../../../shared/models/result-list.model' | ||
8 | import { UserRight } from '../../../shared/models/users/user-right.enum' | ||
9 | import { UserRole } from '../../../shared/models/users/user-role' | ||
10 | |||
11 | export 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 | |||
32 | export 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 | |||
47 | export 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 | |||
59 | export 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 | |||
69 | export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {} | ||