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:
parent
c893d4514e
commit
3fd3ab2d34
150 changed files with 3676 additions and 5074 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue