Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion models/contact/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ async function createUserProfiles (client: MigrationClient): Promise<void> {
const userProfile: UserProfile = {
_id: generateId(),
_class: contact.class.UserProfile,
space: contact.space.Contacts,
space: card.space.Default,

person: d._id,
title,
Expand Down Expand Up @@ -487,6 +487,17 @@ async function fixSocialIdCase (client: MigrationClient): Promise<void> {
}
}

async function migrateUserProfiles (client: MigrationClient): Promise<void> {
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<void> {
await tryMigrate(mode, client, contactId, [
Expand Down Expand Up @@ -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
}
])
},
Expand Down
20 changes: 12 additions & 8 deletions server-plugins/contact-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Person>
const userProfileTx = control.txFactory.createTxCreateDoc<UserProfile>(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<UserProfile>(
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(
Expand Down
Loading