+ if (body.password !== undefined) user.password = body.password
+ if (body.email !== undefined) user.email = body.email
+ if (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy
+ if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
+
+ await sequelizeTypescript.transaction(async t => {
+ await user.save({ transaction: t })
+
+ if (body.displayName !== undefined) user.Account.name = body.displayName
+ if (body.description !== undefined) user.Account.description = body.description
+ await user.Account.save({ transaction: t })
+
+ await sendUpdateActor(user.Account, t)
+
+ auditLogger.update(
+ res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ new UserAuditView(user.toFormattedJSON()),
+ oldUserAuditView
+ )
+ })
+
+ return res.sendStatus(204)
+}
+
+async function updateMyAvatar (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
+ const user: UserModel = res.locals.oauth.token.user
+ const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
+ const account = user.Account
+
+ const avatar = await updateActorAvatarFile(avatarPhysicalFile, account.Actor, account)
+
+ auditLogger.update(
+ res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ new UserAuditView(user.toFormattedJSON()),
+ oldUserAuditView
+ )
+
+ return res
+ .json({
+ avatar: avatar.toFormattedJSON()