Null channel migration fix (#918)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov
2022-02-02 15:22:02 +01:00
committed by GitHub
parent 8eb202c996
commit ba41d98ccf
+1 -2
View File
@@ -72,7 +72,6 @@ async function removeTx (client: MigrationClient, tx: TxCUD<Contact>, doc: Chann
async function processCreateTxes (client: MigrationClient, createTxes: TxCreateDoc<Contact>[]): Promise<Map<Ref<Contact>, Map<Ref<ChannelProvider>, Channel>>> {
const result: Map<Ref<Contact>, Map<Ref<ChannelProvider>, Channel>> = new Map<Ref<Contact>, Map<Ref<ChannelProvider>, Channel>>()
for (const tx of createTxes) {
if (tx.attributes.channels == null) continue
const { channels, ...attributes } = tx.attributes
const current = result.get(tx.objectId)
for (const channel of (channels as any) ?? []) {
@@ -115,7 +114,7 @@ export async function migrateContactChannels (client: MigrationClient, classes:
const contacts = await client.find<Contact>(DOMAIN_CONTACT, { _class: { $in: classes } })
for (const doc of contacts) {
const obj = doc as any
if (obj.channels != null && Array.isArray(obj.channels)) {
if (obj.channels == null || Array.isArray(obj.channels)) {
objectIds.push(doc._id)
}
}