mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-28 04:25:03 +02:00
UBERF-9732: Use huly id as primary social id (#8499)
* uberf-9732: use huly id as primary social id Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com> * uberf-9732: fix person id filter Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
@@ -14,14 +14,8 @@
|
||||
//
|
||||
|
||||
import { TriggerControl } from '@hcengineering/server-core'
|
||||
import contact, {
|
||||
Employee,
|
||||
type Person,
|
||||
PersonSpace,
|
||||
pickPrimarySocialId,
|
||||
SocialIdentityRef
|
||||
} from '@hcengineering/contact'
|
||||
import { AccountUuid, parseSocialIdString, PersonId, type Ref, toIdMap } from '@hcengineering/core'
|
||||
import contact, { Employee, type Person, PersonSpace, SocialIdentityRef } from '@hcengineering/contact'
|
||||
import { AccountUuid, parseSocialIdString, PersonId, type Ref, SocialId, toIdMap } from '@hcengineering/core'
|
||||
|
||||
export async function getCurrentPerson (control: TriggerControl): Promise<Person | undefined> {
|
||||
const { type, value } = parseSocialIdString(control.txFactory.account)
|
||||
@@ -39,13 +33,16 @@ export async function getCurrentPerson (control: TriggerControl): Promise<Person
|
||||
)[0]
|
||||
}
|
||||
|
||||
export async function getSocialStrings (control: TriggerControl, person: Ref<Person>): Promise<PersonId[]> {
|
||||
const socialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, {
|
||||
export async function getSocialIds (control: TriggerControl, person: Ref<Person>): Promise<SocialId[]> {
|
||||
return await control.findAll(control.ctx, contact.class.SocialIdentity, {
|
||||
attachedTo: person,
|
||||
attachedToClass: contact.class.Person
|
||||
attachedToClass: contact.class.Person,
|
||||
verifiedOn: { $gt: 0 }
|
||||
})
|
||||
}
|
||||
|
||||
return socialIdentities.map((s) => s._id)
|
||||
export async function getSocialStrings (control: TriggerControl, person: Ref<Person>): Promise<PersonId[]> {
|
||||
return (await getSocialIds(control, person)).map((s) => s._id)
|
||||
}
|
||||
|
||||
export async function getSocialStringsByPersons (
|
||||
@@ -194,19 +191,6 @@ export async function getSocialIdsByAccounts (
|
||||
}, {})
|
||||
}
|
||||
|
||||
export async function getPrimarySocialIdsByAccounts (
|
||||
control: TriggerControl,
|
||||
accounts: AccountUuid[]
|
||||
): Promise<Record<AccountUuid, PersonId>> {
|
||||
return Object.entries(await getSocialIdsByAccounts(control, accounts)).reduce<Record<AccountUuid, PersonId>>(
|
||||
(acc, [account, sids]) => {
|
||||
acc[account as AccountUuid] = pickPrimarySocialId(sids)
|
||||
return acc
|
||||
},
|
||||
{}
|
||||
)
|
||||
}
|
||||
|
||||
export async function getAccountBySocialId (control: TriggerControl, socialId: PersonId): Promise<AccountUuid | null> {
|
||||
const contextAccount = control.ctx.contextData.socialStringsToUsers.get(socialId)
|
||||
if (contextAccount != null) {
|
||||
|
||||
Reference in New Issue
Block a user