]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/actors/updater.ts
Fix reset sequelize instance
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / actors / updater.ts
index fe94af9f1120da0aaa524a970afba66804b3e433..5a92e7a2241cc6c8fbfc129ce7f50e66f244d7be 100644 (file)
@@ -11,21 +11,14 @@ import { getImagesInfoFromObject } from './shared/object-to-model-attributes'
 
 export class APActorUpdater {
 
-  private accountOrChannel: MAccount | MChannel
-
-  private readonly actorFieldsSave: object
-  private readonly accountOrChannelFieldsSave: object
+  private readonly accountOrChannel: MAccount | MChannel
 
   constructor (
     private readonly actorObject: ActivityPubActor,
     private readonly actor: MActorFull
   ) {
-    this.actorFieldsSave = this.actor.toJSON()
-
     if (this.actorObject.type === 'Group') this.accountOrChannel = this.actor.VideoChannel
     else this.accountOrChannel = this.actor.Account
-
-    this.accountOrChannelFieldsSave = this.accountOrChannel.toJSON()
   }
 
   async update () {
@@ -58,12 +51,12 @@ export class APActorUpdater {
 
       logger.info('Remote account %s updated', this.actorObject.url)
     } catch (err) {
-      if (this.actor !== undefined && this.actorFieldsSave !== undefined) {
-        resetSequelizeInstance(this.actor, this.actorFieldsSave)
+      if (this.actor !== undefined) {
+        await resetSequelizeInstance(this.actor)
       }
 
-      if (this.accountOrChannel !== undefined && this.accountOrChannelFieldsSave !== undefined) {
-        resetSequelizeInstance(this.accountOrChannel, this.accountOrChannelFieldsSave)
+      if (this.accountOrChannel !== undefined) {
+        await resetSequelizeInstance(this.accountOrChannel)
       }
 
       // This is just a debug because we will retry the insert