UBERF-4908 Fix invalid contacts merge (#4347)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-01-12 22:22:57 +07:00 committed by GitHub
parent 3ac0e6e259
commit 573bfd062d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,14 +101,16 @@
async function merge (): Promise<void> { async function merge (): Promise<void> {
if (sourcePerson === undefined || targetPerson === undefined) return if (sourcePerson === undefined || targetPerson === undefined) return
if (Object.keys(update).length > 0) { if (Object.keys(update).length > 0) {
if (update.avatar !== undefined || sourcePerson.avatar === targetPerson.avatar) { const _update = { ...update }
if (_update.avatar !== undefined || sourcePerson.avatar === targetPerson.avatar) {
// We replace avatar, we need to update source with target // We replace avatar, we need to update source with target
await client.update(sourcePerson, { await client.update(sourcePerson, {
avatar: sourcePerson.avatar === targetPerson.avatar ? '' : targetPerson.avatar avatar: sourcePerson.avatar === targetPerson.avatar ? '' : targetPerson.avatar
}) })
} }
await client.update(targetPerson, update) await client.update(targetPerson, _update)
} }
for (const channel of resultChannels.values()) { for (const channel of resultChannels.values()) {
if (channel.attachedTo === targetPerson._id) continue if (channel.attachedTo === targetPerson._id) continue