aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r--server/controllers/api/users.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index 56cbf9448..6540adb1c 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -42,6 +42,7 @@ import { AccountVideoRateModel } from '../../models/account/account-video-rate'
42import { UserModel } from '../../models/account/user' 42import { UserModel } from '../../models/account/user'
43import { OAuthTokenModel } from '../../models/oauth/oauth-token' 43import { OAuthTokenModel } from '../../models/oauth/oauth-token'
44import { VideoModel } from '../../models/video/video' 44import { VideoModel } from '../../models/video/video'
45import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type'
45 46
46const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) 47const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR })
47const loginRateLimiter = new RateLimit({ 48const loginRateLimiter = new RateLimit({
@@ -161,7 +162,13 @@ export {
161 162
162async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 163async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
163 const user = res.locals.oauth.token.User as UserModel 164 const user = res.locals.oauth.token.User as UserModel
164 const resultList = await VideoModel.listAccountVideosForApi(user.Account.id ,req.query.start, req.query.count, req.query.sort) 165 const resultList = await VideoModel.listAccountVideosForApi(
166 user.Account.id,
167 req.query.start as number,
168 req.query.count as number,
169 req.query.sort as VideoSortField,
170 false // Display my NSFW videos
171 )
165 172
166 return res.json(getFormattedObjects(resultList.data, resultList.total)) 173 return res.json(getFormattedObjects(resultList.data, resultList.total))
167} 174}
@@ -188,7 +195,7 @@ async function createUser (req: express.Request) {
188 username: body.username, 195 username: body.username,
189 password: body.password, 196 password: body.password,
190 email: body.email, 197 email: body.email,
191 displayNSFW: false, 198 nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
192 autoPlayVideo: true, 199 autoPlayVideo: true,
193 role: body.role, 200 role: body.role,
194 videoQuota: body.videoQuota 201 videoQuota: body.videoQuota
@@ -219,7 +226,7 @@ async function registerUser (req: express.Request) {
219 username: body.username, 226 username: body.username,
220 password: body.password, 227 password: body.password,
221 email: body.email, 228 email: body.email,
222 displayNSFW: false, 229 nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
223 autoPlayVideo: true, 230 autoPlayVideo: true,
224 role: UserRole.USER, 231 role: UserRole.USER,
225 videoQuota: CONFIG.USER.VIDEO_QUOTA 232 videoQuota: CONFIG.USER.VIDEO_QUOTA
@@ -286,7 +293,7 @@ async function updateMe (req: express.Request, res: express.Response, next: expr
286 293
287 if (body.password !== undefined) user.password = body.password 294 if (body.password !== undefined) user.password = body.password
288 if (body.email !== undefined) user.email = body.email 295 if (body.email !== undefined) user.email = body.email
289 if (body.displayNSFW !== undefined) user.displayNSFW = body.displayNSFW 296 if (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy
290 if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo 297 if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
291 298
292 await sequelizeTypescript.transaction(async t => { 299 await sequelizeTypescript.transaction(async t => {