aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts10
-rw-r--r--server/initializers/database.ts1
-rw-r--r--server/initializers/installer.ts9
-rw-r--r--server/initializers/migrations/0070-user-video-quota.ts32
4 files changed, 45 insertions, 7 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 50a939083..b93a85859 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -15,7 +15,7 @@ import {
15 15
16// --------------------------------------------------------------------------- 16// ---------------------------------------------------------------------------
17 17
18const LAST_MIGRATION_VERSION = 65 18const LAST_MIGRATION_VERSION = 70
19 19
20// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
21 21
@@ -77,7 +77,10 @@ const CONFIG = {
77 }, 77 },
78 SIGNUP: { 78 SIGNUP: {
79 ENABLED: config.get<boolean>('signup.enabled'), 79 ENABLED: config.get<boolean>('signup.enabled'),
80 LIMIT: config.get<number>('signup.limit') 80 LIMIT: config.get<number>('signup.limit'),
81 },
82 USER: {
83 VIDEO_QUOTA: config.get<number>('user.video_quota')
81 }, 84 },
82 TRANSCODING: { 85 TRANSCODING: {
83 ENABLED: config.get<boolean>('transcoding.enabled'), 86 ENABLED: config.get<boolean>('transcoding.enabled'),
@@ -97,7 +100,8 @@ CONFIG.WEBSERVER.HOST = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
97const CONSTRAINTS_FIELDS = { 100const CONSTRAINTS_FIELDS = {
98 USERS: { 101 USERS: {
99 USERNAME: { min: 3, max: 20 }, // Length 102 USERNAME: { min: 3, max: 20 }, // Length
100 PASSWORD: { min: 6, max: 255 } // Length 103 PASSWORD: { min: 6, max: 255 }, // Length
104 VIDEO_QUOTA: { min: -1 }
101 }, 105 },
102 VIDEO_ABUSES: { 106 VIDEO_ABUSES: {
103 REASON: { min: 2, max: 300 } // Length 107 REASON: { min: 2, max: 300 } // Length
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index c0df2b63a..d04c8db1b 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -1,5 +1,6 @@
1import { join } from 'path' 1import { join } from 'path'
2import { flattenDepth } from 'lodash' 2import { flattenDepth } from 'lodash'
3require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string
3import * as Sequelize from 'sequelize' 4import * as Sequelize from 'sequelize'
4import * as Promise from 'bluebird' 5import * as Promise from 'bluebird'
5 6
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 43b5adfed..10b74b85f 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -38,12 +38,12 @@ function removeCacheDirectories () {
38} 38}
39 39
40function createDirectoriesIfNotExist () { 40function createDirectoriesIfNotExist () {
41 const storages = CONFIG.STORAGE 41 const storage = CONFIG.STORAGE
42 const cacheDirectories = CACHE.DIRECTORIES 42 const cacheDirectories = CACHE.DIRECTORIES
43 43
44 const tasks = [] 44 const tasks = []
45 Object.keys(storages).forEach(key => { 45 Object.keys(storage).forEach(key => {
46 const dir = storages[key] 46 const dir = storage[key]
47 tasks.push(mkdirpPromise(dir)) 47 tasks.push(mkdirpPromise(dir))
48 }) 48 })
49 49
@@ -112,7 +112,8 @@ function createOAuthAdminIfNotExist () {
112 username, 112 username,
113 email, 113 email,
114 password, 114 password,
115 role 115 role,
116 videoQuota: -1
116 } 117 }
117 118
118 return db.User.create(userData, createOptions).then(createdUser => { 119 return db.User.create(userData, createOptions).then(createdUser => {
diff --git a/server/initializers/migrations/0070-user-video-quota.ts b/server/initializers/migrations/0070-user-video-quota.ts
new file mode 100644
index 000000000..dec4d46dd
--- /dev/null
+++ b/server/initializers/migrations/0070-user-video-quota.ts
@@ -0,0 +1,32 @@
1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird'
3
4function up (utils: {
5 transaction: Sequelize.Transaction,
6 queryInterface: Sequelize.QueryInterface,
7 sequelize: Sequelize.Sequelize,
8 db: any
9}): Promise<void> {
10 const q = utils.queryInterface
11
12 const data = {
13 type: Sequelize.BIGINT,
14 allowNull: false,
15 defaultValue: -1
16 }
17
18 return q.addColumn('Users', 'videoQuota', data)
19 .then(() => {
20 data.defaultValue = null
21 return q.changeColumn('Users', 'videoQuota', data)
22 })
23}
24
25function down (options) {
26 throw new Error('Not implemented.')
27}
28
29export {
30 up,
31 down
32}