diff options
author | Gérald Niel <gerald.niel@gegeweb.org> | 2018-04-19 19:28:55 +0200 |
---|---|---|
committer | Gérald Niel <gerald.niel@gegeweb.org> | 2018-04-19 19:28:55 +0200 |
commit | 0db1a226507a39b0a663e3e63f04851836a44d5a (patch) | |
tree | 8c8dad658ea5608afaae238cfb6fe803292f908f /server/controllers/api/users.ts | |
parent | 0030284b0df2983914291d6fe83675e2aa892e6a (diff) | |
parent | d4f3fea659163749f9ea879a5e1dd313106353c6 (diff) | |
download | PeerTube-0db1a226507a39b0a663e3e63f04851836a44d5a.tar.gz PeerTube-0db1a226507a39b0a663e3e63f04851836a44d5a.tar.zst PeerTube-0db1a226507a39b0a663e3e63f04851836a44d5a.zip |
Merge branch 'develop' of framagit.org:chocobozzz/PeerTube into develop
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r-- | server/controllers/api/users.ts | 15 |
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' | |||
42 | import { UserModel } from '../../models/account/user' | 42 | import { UserModel } from '../../models/account/user' |
43 | import { OAuthTokenModel } from '../../models/oauth/oauth-token' | 43 | import { OAuthTokenModel } from '../../models/oauth/oauth-token' |
44 | import { VideoModel } from '../../models/video/video' | 44 | import { VideoModel } from '../../models/video/video' |
45 | import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type' | ||
45 | 46 | ||
46 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) | 47 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) |
47 | const loginRateLimiter = new RateLimit({ | 48 | const loginRateLimiter = new RateLimit({ |
@@ -161,7 +162,13 @@ export { | |||
161 | 162 | ||
162 | async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 163 | async 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 => { |