From 6fcd19ba737f1f5614a56c6925adb882dea43b8d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 Jul 2017 13:26:25 +0200 Subject: Move to promises Closes https://github.com/Chocobozzz/PeerTube/issues/74 --- server/models/user/user-interface.ts | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'server/models/user/user-interface.ts') 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 @@ import * as Sequelize from 'sequelize' -import * as Bluebird from 'bluebird' +import * as Promise from 'bluebird' // Don't use barrel, import just what we need import { UserRole, User as FormatedUser } from '../../../shared/models/user.model' +import { ResultList } from '../../../shared/models/result-list.model' export namespace UserMethods { - export type IsPasswordMatchCallback = (err: Error, same: boolean) => void - export type IsPasswordMatch = (this: UserInstance, password: string, callback: IsPasswordMatchCallback) => void + export type IsPasswordMatch = (this: UserInstance, password: string) => Promise export type ToFormatedJSON = (this: UserInstance) => FormatedUser export type IsAdmin = (this: UserInstance) => boolean - export type CountTotalCallback = (err: Error, total: number) => void - export type CountTotal = (callback: CountTotalCallback) => void + export type CountTotal = () => Promise - export type GetByUsername = (username: string) => Bluebird + export type GetByUsername = (username: string) => Promise - export type ListCallback = (err: Error, userInstances: UserInstance[]) => void - export type List = (callback: ListCallback) => void + export type List = () => Promise - export type ListForApiCallback = (err: Error, userInstances?: UserInstance[], total?: number) => void - export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void + export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList > - export type LoadByIdCallback = (err: Error, userInstance: UserInstance) => void - export type LoadById = (id: number, callback: LoadByIdCallback) => void + export type LoadById = (id: number) => Promise - export type LoadByUsernameCallback = (err: Error, userInstance: UserInstance) => void - export type LoadByUsername = (username: string, callback: LoadByUsernameCallback) => void + export type LoadByUsername = (username: string) => Promise - export type LoadByUsernameOrEmailCallback = (err: Error, userInstance: UserInstance) => void - export type LoadByUsernameOrEmail = (username: string, email: string, callback: LoadByUsernameOrEmailCallback) => void + export type LoadByUsernameOrEmail = (username: string, email: string) => Promise } export interface UserClass { -- cgit v1.2.3