Skip to content

Commit

Permalink
fix: identity storage in db
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed May 27, 2018
1 parent b643a74 commit 0e82529
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
})
Expand Down
5 changes: 4 additions & 1 deletion src/identities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
Env,
Logger,
Objects,
Storage,
DB,
Bucket,
ModelStore,
Expand All @@ -56,6 +57,7 @@ type PubKeyMapping = {
type IdentitiesOpts = {
db: DB,
objects: Objects
storage: Storage
modelStore: ModelStore
logger: Logger
}
Expand All @@ -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
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 0e82529

Please sign in to comment.