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:
Alexey Zinoviev
2025-04-09 09:52:06 +07:00
committed by GitHub
parent 420b31d66f
commit 4cb1f3e411
29 changed files with 478 additions and 238 deletions
@@ -1,7 +1,7 @@
//
// Copyright © 2023-2024 Hardcore Engineering Inc.
//
import { Person, pickPrimarySocialId, type Employee } from '@hcengineering/contact'
import { Person, type Employee } from '@hcengineering/contact'
import core, {
AccountRole,
combineAttributes,
@@ -13,14 +13,15 @@ import core, {
TxCreateDoc,
TxFactory,
TxUpdateDoc,
systemAccountUuid,
pickPrimarySocialId,
type Doc,
type RolesAssignment,
type Timestamp,
type TxCUD,
systemAccountUuid
type TxCUD
} from '@hcengineering/core'
import { NotificationType } from '@hcengineering/notification'
import { getEmployees, getSocialStrings } from '@hcengineering/server-contact'
import { getEmployees, getSocialIds } from '@hcengineering/server-contact'
import { TriggerControl } from '@hcengineering/server-core'
import documents, {
@@ -130,9 +131,14 @@ async function createDocumentTrainingRequest (doc: ControlledDocument, control:
const dueDate: Timestamp | null =
documentTraining.dueDays === null ? null : doc.effectiveDate + documentTraining.dueDays * 24 * 60 * 60 * 1000
const ownerSocialStrings = await getSocialStrings(control, doc.owner)
const ownerSocialIds = await getSocialIds(control, doc.owner)
if (ownerSocialIds.length === 0) {
console.error(`Owner ${doc.owner} has no social ids`)
return []
}
// TODO: Encapsulate training request creation logic in training plugin?
const modifiedBy = pickPrimarySocialId(ownerSocialStrings)
const modifiedBy = pickPrimarySocialId(ownerSocialIds)._id
let trainees: Array<Ref<Employee>> = documentTraining.trainees
const roles = documentTraining.roles