X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fuser%2Fuser-interface.ts;h=1b5233eaff509b9e3463ae54fe8dae3b6a32ca6b;hb=72c7248b6fdcdb2175e726ff51b42e7555f2bd84;hp=48c67678ba7c6414c3efa14866e7ae1194f52a46;hpb=154898b0b7bc1af41fc5a94974e338a3590c90f3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts index 48c67678b..1b5233eaf 100644 --- a/server/models/user/user-interface.ts +++ b/server/models/user/user-interface.ts @@ -1,57 +1,58 @@ 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 { User as FormattedUser } from '../../../shared/models/users/user.model' +import { UserRole } from '../../../shared/models/users/user-role.type' +import { ResultList } from '../../../shared/models/result-list.model' +import { AuthorInstance } from '../video/author-interface' 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 ToFormattedJSON = (this: UserInstance) => FormattedUser export type IsAdmin = (this: UserInstance) => boolean + export type IsAbleToUploadVideo = (this: UserInstance, videoFile: Express.Multer.File) => Promise - 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 ListForApi = (start: number, count: number, sort: string) => Promise< ResultList > - export type ListForApiCallback = (err: Error, userInstances?: UserInstance[], total?: number) => void - export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void + export type LoadById = (id: number) => Promise - export type LoadByIdCallback = (err: Error, userInstance: UserInstance) => void - export type LoadById = (id: number, callback: LoadByIdCallback) => void + export type LoadByUsername = (username: string) => Promise + export type LoadByUsernameAndPopulateChannels = (username: string) => Promise - export type LoadByUsernameCallback = (err: Error, userInstance: UserInstance) => void - export type LoadByUsername = (username: string, callback: LoadByUsernameCallback) => void - - 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 { isPasswordMatch: UserMethods.IsPasswordMatch, - toFormatedJSON: UserMethods.ToFormatedJSON, + toFormattedJSON: UserMethods.ToFormattedJSON, isAdmin: UserMethods.IsAdmin, + isAbleToUploadVideo: UserMethods.IsAbleToUploadVideo, countTotal: UserMethods.CountTotal, getByUsername: UserMethods.GetByUsername, - list: UserMethods.List, listForApi: UserMethods.ListForApi, loadById: UserMethods.LoadById, loadByUsername: UserMethods.LoadByUsername, + loadByUsernameAndPopulateChannels: UserMethods.LoadByUsernameAndPopulateChannels, loadByUsernameOrEmail: UserMethods.LoadByUsernameOrEmail } export interface UserAttributes { + id?: number password: string username: string email: string displayNSFW?: boolean role: UserRole + videoQuota: number + + Author?: AuthorInstance } export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance { @@ -60,7 +61,7 @@ export interface UserInstance extends UserClass, UserAttributes, Sequelize.Insta updatedAt: Date isPasswordMatch: UserMethods.IsPasswordMatch - toFormatedJSON: UserMethods.ToFormatedJSON + toFormattedJSON: UserMethods.ToFormattedJSON isAdmin: UserMethods.IsAdmin }