import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { JobQueue } from '../../../lib/job-queue'
import { logger } from '../../../helpers/logger'
+import { AccountModel } from '../../../models/account/account'
const auditLogger = auditLoggerFactory('users-me')
meRouter.put('/me',
authenticate,
- usersUpdateMeValidator,
+ asyncMiddleware(usersUpdateMeValidator),
asyncRetryTransactionMiddleware(updateMe)
)
nsfw: buildNSFWFilter(res, req.query.nsfw),
filter: req.query.filter as VideoFilter,
withFiles: false,
- actorId: user.Account.Actor.id
+ actorId: user.Account.Actor.id,
+ user
})
return res.json(getFormattedObjects(resultList.data, resultList.total))
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.webTorrentEnabled !== undefined) user.webTorrentEnabled = body.webTorrentEnabled
if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
await sequelizeTypescript.transaction(async t => {
+ const userAccount = await AccountModel.load(user.Account.id)
+
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 })
+ if (body.displayName !== undefined) userAccount.name = body.displayName
+ if (body.description !== undefined) userAccount.description = body.description
+ await userAccount.save({ transaction: t })
- await sendUpdateActor(user.Account, t)
+ await sendUpdateActor(userAccount, t)
- auditLogger.update(
- getAuditIdFromRes(res),
- new UserAuditView(user.toFormattedJSON()),
- oldUserAuditView
- )
+ auditLogger.update(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()), oldUserAuditView)
})
return res.sendStatus(204)
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)
+ const userAccount = await AccountModel.load(user.Account.id)
- auditLogger.update(
- getAuditIdFromRes(res),
- new UserAuditView(user.toFormattedJSON()),
- oldUserAuditView
- )
+ const avatar = await updateActorAvatarFile(avatarPhysicalFile, userAccount)
+
+ auditLogger.update(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()), oldUserAuditView)
return res.json({ avatar: avatar.toFormattedJSON() })
}