aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-15 14:46:26 +0100
committerChocobozzz <me@florianbigard.com>2018-02-15 15:29:07 +0100
commit2422c46b27790d94fd29a7092170cee5a1b56008 (patch)
treed5c1942ce20cadb27a551d87c789edfe92f5b105 /server/controllers/api/users.ts
parent34cbef8c6cc912143a421413bdd832c4adcc556a (diff)
downloadPeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip
Implement support field in video and video channel
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r--server/controllers/api/users.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index e3067584e..583376c38 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -9,7 +9,7 @@ import { logger } from '../../helpers/logger'
9import { createReqFiles, getFormattedObjects } from '../../helpers/utils' 9import { createReqFiles, getFormattedObjects } from '../../helpers/utils'
10import { AVATARS_SIZE, CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' 10import { AVATARS_SIZE, CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers'
11import { updateActorAvatarInstance } from '../../lib/activitypub' 11import { updateActorAvatarInstance } from '../../lib/activitypub'
12import { sendUpdateUser } from '../../lib/activitypub/send' 12import { sendUpdateActor } from '../../lib/activitypub/send'
13import { Emailer } from '../../lib/emailer' 13import { Emailer } from '../../lib/emailer'
14import { Redis } from '../../lib/redis' 14import { Redis } from '../../lib/redis'
15import { createUserAccountAndChannel } from '../../lib/user' 15import { createUserAccountAndChannel } from '../../lib/user'
@@ -270,15 +270,21 @@ async function removeUser (req: express.Request, res: express.Response, next: ex
270async function updateMe (req: express.Request, res: express.Response, next: express.NextFunction) { 270async function updateMe (req: express.Request, res: express.Response, next: express.NextFunction) {
271 const body: UserUpdateMe = req.body 271 const body: UserUpdateMe = req.body
272 272
273 const user = res.locals.oauth.token.user 273 const user: UserModel = res.locals.oauth.token.user
274 274
275 if (body.password !== undefined) user.password = body.password 275 if (body.password !== undefined) user.password = body.password
276 if (body.email !== undefined) user.email = body.email 276 if (body.email !== undefined) user.email = body.email
277 if (body.displayNSFW !== undefined) user.displayNSFW = body.displayNSFW 277 if (body.displayNSFW !== undefined) user.displayNSFW = body.displayNSFW
278 if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo 278 if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
279 279
280 await user.save() 280 await sequelizeTypescript.transaction(async t => {
281 await sendUpdateUser(user, undefined) 281 await user.save({ transaction: t })
282
283 if (body.description !== undefined) user.Account.description = body.description
284 await user.Account.save({ transaction: t })
285
286 await sendUpdateActor(user.Account, t)
287 })
282 288
283 return res.sendStatus(204) 289 return res.sendStatus(204)
284} 290}
@@ -297,7 +303,7 @@ async function updateMyAvatar (req: express.Request, res: express.Response, next
297 const updatedActor = await updateActorAvatarInstance(actor, avatarName, t) 303 const updatedActor = await updateActorAvatarInstance(actor, avatarName, t)
298 await updatedActor.save({ transaction: t }) 304 await updatedActor.save({ transaction: t })
299 305
300 await sendUpdateUser(user, t) 306 await sendUpdateActor(user.Account, t)
301 307
302 return updatedActor.Avatar 308 return updatedActor.Avatar
303 }) 309 })