- try {
- await sequelizeTypescript.transaction(async t => {
- actorFieldsSave = actor.toJSON()
-
- if (actorAttributesToUpdate.type === 'Group') accountOrChannelInstance = actor.VideoChannel
- else accountOrChannelInstance = actor.Account
-
- accountOrChannelFieldsSave = accountOrChannelInstance.toJSON()
-
- await updateActorInstance(actor, actorAttributesToUpdate)
-
- if (avatarName !== undefined) {
- await updateActorAvatarInstance(actor, avatarName, t)
- }
-
- await actor.save({ transaction: t })
-
- accountOrChannelInstance.set('name', actorAttributesToUpdate.name || actorAttributesToUpdate.preferredUsername)
- accountOrChannelInstance.set('description', actorAttributesToUpdate.summary)
- accountOrChannelInstance.set('support', actorAttributesToUpdate.support)
- await accountOrChannelInstance.save({ transaction: t })
- })
-
- logger.info('Remote account with uuid %s updated', actorAttributesToUpdate.uuid)
- } catch (err) {
- if (actor !== undefined && actorFieldsSave !== undefined) {
- resetSequelizeInstance(actor, actorFieldsSave)
- }
-
- if (accountOrChannelInstance !== undefined && accountOrChannelFieldsSave !== undefined) {
- resetSequelizeInstance(accountOrChannelInstance, accountOrChannelFieldsSave)
- }
-
- // This is just a debug because we will retry the insert
- logger.debug('Cannot update the remote account.', { err })
- throw err
- }