- 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 (avatarInfo !== undefined) {
- const avatarOptions = Object.assign({}, avatarInfo, { onDisk: false })
-
- await updateActorAvatarInstance(actor, avatarOptions, t)
- }
-
- await actor.save({ transaction: t })
-
- accountOrChannelInstance.name = actorAttributesToUpdate.name || actorAttributesToUpdate.preferredUsername
- accountOrChannelInstance.description = actorAttributesToUpdate.summary
-
- if (accountOrChannelInstance instanceof VideoChannelModel) accountOrChannelInstance.support = actorAttributesToUpdate.support
-
- await accountOrChannelInstance.save({ transaction: t })
- })
-
- logger.info('Remote account %s updated', actorAttributesToUpdate.url)
- } 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
- }