1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Move models to typescript-sequelize

This commit is contained in:
Chocobozzz 2017-12-12 17:53:50 +01:00
parent c893d4514e
commit 3fd3ab2d34
No known key found for this signature in database
GPG key ID: 583A612D890159BE
150 changed files with 3676 additions and 5074 deletions

View file

@ -2,8 +2,7 @@ import * as Bluebird from 'bluebird'
import { Response } from 'express'
import 'express-validator'
import * as validator from 'validator'
import { database as db } from '../../initializers'
import { AccountInstance } from '../../models'
import { AccountModel } from '../../models/account/account'
import { isUserUsernameValid } from './users'
function isAccountNameValid (value: string) {
@ -11,24 +10,24 @@ function isAccountNameValid (value: string) {
}
function isAccountIdExist (id: number | string, res: Response) {
let promise: Bluebird<AccountInstance>
let promise: Bluebird<AccountModel>
if (validator.isInt('' + id)) {
promise = db.Account.load(+id)
promise = AccountModel.load(+id)
} else { // UUID
promise = db.Account.loadByUUID('' + id)
promise = AccountModel.loadByUUID('' + id)
}
return isAccountExist(promise, res)
}
function isLocalAccountNameExist (name: string, res: Response) {
const promise = db.Account.loadLocalByName(name)
const promise = AccountModel.loadLocalByName(name)
return isAccountExist(promise, res)
}
async function isAccountExist (p: Bluebird<AccountInstance>, res: Response) {
async function isAccountExist (p: Bluebird<AccountModel>, res: Response) {
const account = await p
if (!account) {