From f386c32cea16644887b44ca295755c50df3d4a85 Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Sun, 5 Oct 2025 23:09:02 +0400 Subject: [PATCH] Qfix: move user profile to default card space Signed-off-by: Alexey Zinoviev --- models/contact/src/migration.ts | 18 ++++++++++++++++- server-plugins/contact-resources/src/index.ts | 20 +++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/models/contact/src/migration.ts b/models/contact/src/migration.ts index 8a675c3513d..985123c762b 100644 --- a/models/contact/src/migration.ts +++ b/models/contact/src/migration.ts @@ -430,7 +430,7 @@ async function createUserProfiles (client: MigrationClient): Promise { const userProfile: UserProfile = { _id: generateId(), _class: contact.class.UserProfile, - space: contact.space.Contacts, + space: card.space.Default, person: d._id, title, @@ -487,6 +487,17 @@ async function fixSocialIdCase (client: MigrationClient): Promise { } } +async function migrateUserProfiles (client: MigrationClient): Promise { + await client.update( + DOMAIN_CARD, + { + _class: contact.class.UserProfile, + space: contact.space.Contacts + }, + { space: card.space.Default } + ) +} + export const contactOperation: MigrateOperation = { async preMigrate (client: MigrationClient, logger: ModelLogger, mode): Promise { await tryMigrate(mode, client, contactId, [ @@ -673,6 +684,11 @@ export const contactOperation: MigrateOperation = { state: 'fix-social-id-case', mode: 'upgrade', func: fixSocialIdCase + }, + { + state: 'migrate-user-profiles', + mode: 'upgrade', + func: migrateUserProfiles } ]) }, diff --git a/server-plugins/contact-resources/src/index.ts b/server-plugins/contact-resources/src/index.ts index e759f7c74fa..a4bba62ceaa 100644 --- a/server-plugins/contact-resources/src/index.ts +++ b/server-plugins/contact-resources/src/index.ts @@ -254,14 +254,18 @@ export async function OnPersonCreate (_txes: Tx[], control: TriggerControl): Pro const result: Tx[] = [] for (const tx of _txes) { const ctx = tx as TxCreateDoc - const userProfileTx = control.txFactory.createTxCreateDoc(contact.class.UserProfile, ctx.objectSpace, { - person: ctx.objectId, - title: formatName(ctx.attributes.name), - rank: makeRank(undefined, undefined), - content: '' as MarkupBlobRef, - parentInfo: [], - blobs: {} - }) + const userProfileTx = control.txFactory.createTxCreateDoc( + contact.class.UserProfile, + card.space.Default, + { + person: ctx.objectId, + title: formatName(ctx.attributes.name), + rank: makeRank(undefined, undefined), + content: '' as MarkupBlobRef, + parentInfo: [], + blobs: {} + } + ) result.push(userProfileTx) result.push(