diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/config.ts | 7 | ||||
-rw-r--r-- | server/controllers/api/users/index.ts | 7 | ||||
-rw-r--r-- | server/controllers/api/users/me.ts | 4 |
3 files changed, 13 insertions, 5 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index b25f739bb..3fd355e6d 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -103,7 +103,8 @@ async function getConfig (req: express.Request, res: express.Response, next: exp | |||
103 | } | 103 | } |
104 | }, | 104 | }, |
105 | user: { | 105 | user: { |
106 | videoQuota: CONFIG.USER.VIDEO_QUOTA | 106 | videoQuota: CONFIG.USER.VIDEO_QUOTA, |
107 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY | ||
107 | } | 108 | } |
108 | } | 109 | } |
109 | 110 | ||
@@ -154,6 +155,7 @@ async function updateCustomConfig (req: express.Request, res: express.Response, | |||
154 | toUpdate.cache.captions.size = parseInt('' + toUpdate.cache.captions.size, 10) | 155 | toUpdate.cache.captions.size = parseInt('' + toUpdate.cache.captions.size, 10) |
155 | toUpdate.signup.limit = parseInt('' + toUpdate.signup.limit, 10) | 156 | toUpdate.signup.limit = parseInt('' + toUpdate.signup.limit, 10) |
156 | toUpdate.user.videoQuota = parseInt('' + toUpdate.user.videoQuota, 10) | 157 | toUpdate.user.videoQuota = parseInt('' + toUpdate.user.videoQuota, 10) |
158 | toUpdate.user.videoQuotaDaily = parseInt('' + toUpdate.user.videoQuotaDaily, 10) | ||
157 | toUpdate.transcoding.threads = parseInt('' + toUpdate.transcoding.threads, 10) | 159 | toUpdate.transcoding.threads = parseInt('' + toUpdate.transcoding.threads, 10) |
158 | 160 | ||
159 | // camelCase to snake_case key | 161 | // camelCase to snake_case key |
@@ -223,7 +225,8 @@ function customConfig (): CustomConfig { | |||
223 | email: CONFIG.ADMIN.EMAIL | 225 | email: CONFIG.ADMIN.EMAIL |
224 | }, | 226 | }, |
225 | user: { | 227 | user: { |
226 | videoQuota: CONFIG.USER.VIDEO_QUOTA | 228 | videoQuota: CONFIG.USER.VIDEO_QUOTA, |
229 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY | ||
227 | }, | 230 | }, |
228 | transcoding: { | 231 | transcoding: { |
229 | enabled: CONFIG.TRANSCODING.ENABLED, | 232 | enabled: CONFIG.TRANSCODING.ENABLED, |
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index 608d439ac..25d51ae5e 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -134,7 +134,8 @@ async function createUser (req: express.Request, res: express.Response) { | |||
134 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, | 134 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, |
135 | autoPlayVideo: true, | 135 | autoPlayVideo: true, |
136 | role: body.role, | 136 | role: body.role, |
137 | videoQuota: body.videoQuota | 137 | videoQuota: body.videoQuota, |
138 | videoQuotaDaily: body.videoQuotaDaily | ||
138 | }) | 139 | }) |
139 | 140 | ||
140 | const { user, account } = await createUserAccountAndChannel(userToCreate) | 141 | const { user, account } = await createUserAccountAndChannel(userToCreate) |
@@ -163,7 +164,8 @@ async function registerUser (req: express.Request, res: express.Response) { | |||
163 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, | 164 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, |
164 | autoPlayVideo: true, | 165 | autoPlayVideo: true, |
165 | role: UserRole.USER, | 166 | role: UserRole.USER, |
166 | videoQuota: CONFIG.USER.VIDEO_QUOTA | 167 | videoQuota: CONFIG.USER.VIDEO_QUOTA, |
168 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY | ||
167 | }) | 169 | }) |
168 | 170 | ||
169 | const { user } = await createUserAccountAndChannel(userToCreate) | 171 | const { user } = await createUserAccountAndChannel(userToCreate) |
@@ -219,6 +221,7 @@ async function updateUser (req: express.Request, res: express.Response, next: ex | |||
219 | 221 | ||
220 | if (body.email !== undefined) userToUpdate.email = body.email | 222 | if (body.email !== undefined) userToUpdate.email = body.email |
221 | if (body.videoQuota !== undefined) userToUpdate.videoQuota = body.videoQuota | 223 | if (body.videoQuota !== undefined) userToUpdate.videoQuota = body.videoQuota |
224 | if (body.videoQuotaDaily !== undefined) userToUpdate.videoQuotaDaily = body.videoQuotaDaily | ||
222 | if (body.role !== undefined) userToUpdate.role = body.role | 225 | if (body.role !== undefined) userToUpdate.role = body.role |
223 | 226 | ||
224 | const user = await userToUpdate.save() | 227 | const user = await userToUpdate.save() |
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 000c706b5..0f18b42f9 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -283,9 +283,11 @@ async function getUserVideoQuotaUsed (req: express.Request, res: express.Respons | |||
283 | // We did not load channels in res.locals.user | 283 | // We did not load channels in res.locals.user |
284 | const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) | 284 | const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) |
285 | const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) | 285 | const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) |
286 | const videoQuotaUsedDaily = await UserModel.getOriginalVideoFileTotalDailyFromUser(user) | ||
286 | 287 | ||
287 | const data: UserVideoQuota = { | 288 | const data: UserVideoQuota = { |
288 | videoQuotaUsed | 289 | videoQuotaUsed, |
290 | videoQuotaUsedDaily | ||
289 | } | 291 | } |
290 | return res.json(data) | 292 | return res.json(data) |
291 | } | 293 | } |