From 0e825290b216c54bbdd4b1891dcb3450d2ea8c66 Mon Sep 17 00:00:00 2001 From: Mark Vayngrib Date: Sun, 27 May 2018 11:39:51 -0400 Subject: [PATCH] fix: identity storage in db --- src/bot.ts | 1 + src/identities.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index 74264880f..46adb585d 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -512,6 +512,7 @@ export class Bot extends EventEmitter implements IReady, IHasModels { logger: bot.logger.sub('identities'), modelStore, // circular ref + get storage() { return bot.storage }, get db() { return bot.db }, get objects() { return bot.objects }, }) diff --git a/src/identities.ts b/src/identities.ts index f75afc9ca..9dec7f991 100644 --- a/src/identities.ts +++ b/src/identities.ts @@ -30,6 +30,7 @@ import { Env, Logger, Objects, + Storage, DB, Bucket, ModelStore, @@ -56,6 +57,7 @@ type PubKeyMapping = { type IdentitiesOpts = { db: DB, objects: Objects + storage: Storage modelStore: ModelStore logger: Logger } @@ -69,6 +71,7 @@ export default class Identities implements IHasLogger { private get modelStore() { return this.components.modelStore } private get db() { return this.components.db } private get objects() { return this.components.objects } + private get storage() { return this.components.storage } private components: IdentitiesOpts private _cachePub: Function private _cacheIdentity: Function @@ -323,7 +326,7 @@ export default class Identities implements IHasLogger { this._cacheIdentity(object) this.logger.info('adding contact', { permalink }) - await Promise.all(putPubKeys.concat(this.objects.put(object))) + await Promise.all(putPubKeys.concat(this.storage.save({ object }))) } public putPubKey = (props: {