-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate and drop old person database
Signed-off-by: Jack Works <[email protected]>
- Loading branch information
1 parent
3dd9215
commit 2bf4443
Showing
11 changed files
with
67 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import avatar from './old.avatar.1' | ||
import localKeys from './old.localKeys.1' | ||
import keys from './old.keystore.1' | ||
|
||
avatar() | ||
localKeys() | ||
keys() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { deleteDB } from 'idb/with-async-ittr' | ||
import * as People from '../people' | ||
import { queryPeopleCryptoKey } from '../../key-management/keystore-db' | ||
import { PersonIdentifier } from '../type' | ||
|
||
/** | ||
* ! Migrate old database into new one. | ||
* ! Scheduled to remove it after May/31/2019 | ||
*/ | ||
export default async function migrate() { | ||
if (indexedDB.databases) { | ||
const dbs = await indexedDB.databases() | ||
if (!dbs.find(x => x.name === 'maskbook-keystore-demo-v2')) return | ||
} | ||
// tslint:disable-next-line: deprecation | ||
const wait = (await queryPeopleCryptoKey()).map(record => { | ||
if (record.username === '$self') | ||
return People.storeMyIdentityDB({ | ||
// TODO: Need to update later ! | ||
identifier: new PersonIdentifier('facebook.com', '$self'), | ||
groups: [], | ||
relation: [], | ||
relationLastCheckTime: new Date(), | ||
publicKey: record.publicKey, | ||
privateKey: record.privateKey!, | ||
}) | ||
else | ||
return People.storeNewPersonDB({ | ||
identifier: new PersonIdentifier('facebook.com', record.username), | ||
publicKey: record.publicKey, | ||
groups: [], | ||
relation: [], | ||
relationLastCheckTime: new Date('May 1 2019'), | ||
}) | ||
}) | ||
await Promise.all(wait) | ||
await deleteDB('maskbook-keystore-demo-v2') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters