aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user/user-interface.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-05 13:26:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-05 14:14:16 +0200
commit6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch)
tree3365a96d82bc7f00ae504a568725c8e914150cf8 /server/models/user/user-interface.ts
parent5fe7e898316e18369c3e1aba307b55077adc7bfb (diff)
downloadPeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'server/models/user/user-interface.ts')
-rw-r--r--server/models/user/user-interface.ts26
1 files changed, 10 insertions, 16 deletions
diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts
index 48c67678b..f743945f8 100644
--- a/server/models/user/user-interface.ts
+++ b/server/models/user/user-interface.ts
@@ -1,35 +1,29 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Bluebird from 'bluebird' 2import * as Promise from 'bluebird'
3 3
4// Don't use barrel, import just what we need 4// Don't use barrel, import just what we need
5import { UserRole, User as FormatedUser } from '../../../shared/models/user.model' 5import { UserRole, User as FormatedUser } from '../../../shared/models/user.model'
6import { ResultList } from '../../../shared/models/result-list.model'
6 7
7export namespace UserMethods { 8export namespace UserMethods {
8 export type IsPasswordMatchCallback = (err: Error, same: boolean) => void 9 export type IsPasswordMatch = (this: UserInstance, password: string) => Promise<boolean>
9 export type IsPasswordMatch = (this: UserInstance, password: string, callback: IsPasswordMatchCallback) => void
10 10
11 export type ToFormatedJSON = (this: UserInstance) => FormatedUser 11 export type ToFormatedJSON = (this: UserInstance) => FormatedUser
12 export type IsAdmin = (this: UserInstance) => boolean 12 export type IsAdmin = (this: UserInstance) => boolean
13 13
14 export type CountTotalCallback = (err: Error, total: number) => void 14 export type CountTotal = () => Promise<number>
15 export type CountTotal = (callback: CountTotalCallback) => void
16 15
17 export type GetByUsername = (username: string) => Bluebird<UserInstance> 16 export type GetByUsername = (username: string) => Promise<UserInstance>
18 17
19 export type ListCallback = (err: Error, userInstances: UserInstance[]) => void 18 export type List = () => Promise<UserInstance[]>
20 export type List = (callback: ListCallback) => void
21 19
22 export type ListForApiCallback = (err: Error, userInstances?: UserInstance[], total?: number) => void 20 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<UserInstance> >
23 export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void
24 21
25 export type LoadByIdCallback = (err: Error, userInstance: UserInstance) => void 22 export type LoadById = (id: number) => Promise<UserInstance>
26 export type LoadById = (id: number, callback: LoadByIdCallback) => void
27 23
28 export type LoadByUsernameCallback = (err: Error, userInstance: UserInstance) => void 24 export type LoadByUsername = (username: string) => Promise<UserInstance>
29 export type LoadByUsername = (username: string, callback: LoadByUsernameCallback) => void
30 25
31 export type LoadByUsernameOrEmailCallback = (err: Error, userInstance: UserInstance) => void 26 export type LoadByUsernameOrEmail = (username: string, email: string) => Promise<UserInstance>
32 export type LoadByUsernameOrEmail = (username: string, email: string, callback: LoadByUsernameOrEmailCallback) => void
33} 27}
34 28
35export interface UserClass { 29export interface UserClass {