diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/helpers/utils.ts | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip |
Move models to typescript-sequelize
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r-- | server/helpers/utils.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 3464341e6..cb5e536b8 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as Sequelize from 'sequelize' | 2 | import { Model } from 'sequelize-typescript' |
3 | import { ResultList } from '../../shared' | 3 | import { ResultList } from '../../shared' |
4 | import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' | 4 | import { VideoResolution } from '../../shared/models/videos' |
5 | import { CONFIG, database as db } from '../initializers' | 5 | import { CONFIG } from '../initializers' |
6 | import { AccountInstance } from '../models/account/account-interface' | 6 | import { AccountModel } from '../models/account/account' |
7 | import { UserModel } from '../models/account/user' | ||
7 | import { pseudoRandomBytesPromise } from './core-utils' | 8 | import { pseudoRandomBytesPromise } from './core-utils' |
8 | import { logger } from './logger' | 9 | import { logger } from './logger' |
9 | 10 | ||
@@ -46,7 +47,7 @@ async function isSignupAllowed () { | |||
46 | return true | 47 | return true |
47 | } | 48 | } |
48 | 49 | ||
49 | const totalUsers = await db.User.countTotal() | 50 | const totalUsers = await UserModel.countTotal() |
50 | 51 | ||
51 | return totalUsers < CONFIG.SIGNUP.LIMIT | 52 | return totalUsers < CONFIG.SIGNUP.LIMIT |
52 | } | 53 | } |
@@ -72,17 +73,17 @@ function computeResolutionsToTranscode (videoFileHeight: number) { | |||
72 | return resolutionsEnabled | 73 | return resolutionsEnabled |
73 | } | 74 | } |
74 | 75 | ||
75 | function resetSequelizeInstance (instance: Sequelize.Instance<any>, savedFields: object) { | 76 | function resetSequelizeInstance (instance: Model<any>, savedFields: object) { |
76 | Object.keys(savedFields).forEach(key => { | 77 | Object.keys(savedFields).forEach(key => { |
77 | const value = savedFields[key] | 78 | const value = savedFields[key] |
78 | instance.set(key, value) | 79 | instance.set(key, value) |
79 | }) | 80 | }) |
80 | } | 81 | } |
81 | 82 | ||
82 | let serverAccount: AccountInstance | 83 | let serverAccount: AccountModel |
83 | async function getServerAccount () { | 84 | async function getServerAccount () { |
84 | if (serverAccount === undefined) { | 85 | if (serverAccount === undefined) { |
85 | serverAccount = await db.Account.loadApplication() | 86 | serverAccount = await AccountModel.loadApplication() |
86 | } | 87 | } |
87 | 88 | ||
88 | if (!serverAccount) { | 89 | if (!serverAccount) { |