diff options
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r-- | server/controllers/api/users.ts | 16 |
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' | |||
9 | import { createReqFiles, getFormattedObjects } from '../../helpers/utils' | 9 | import { createReqFiles, getFormattedObjects } from '../../helpers/utils' |
10 | import { AVATARS_SIZE, CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' | 10 | import { AVATARS_SIZE, CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' |
11 | import { updateActorAvatarInstance } from '../../lib/activitypub' | 11 | import { updateActorAvatarInstance } from '../../lib/activitypub' |
12 | import { sendUpdateUser } from '../../lib/activitypub/send' | 12 | import { sendUpdateActor } from '../../lib/activitypub/send' |
13 | import { Emailer } from '../../lib/emailer' | 13 | import { Emailer } from '../../lib/emailer' |
14 | import { Redis } from '../../lib/redis' | 14 | import { Redis } from '../../lib/redis' |
15 | import { createUserAccountAndChannel } from '../../lib/user' | 15 | import { createUserAccountAndChannel } from '../../lib/user' |
@@ -270,15 +270,21 @@ async function removeUser (req: express.Request, res: express.Response, next: ex | |||
270 | async function updateMe (req: express.Request, res: express.Response, next: express.NextFunction) { | 270 | async 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 | }) |