15
15
16
16
import { TriggerControl } from '@hcengineering/server-core'
17
17
import contact , { Employee , type Person , PersonSpace , SocialIdentityRef } from '@hcengineering/contact'
18
- import { AccountUuid , parseSocialIdString , PersonId , type Ref , SocialId , toIdMap } from '@hcengineering/core'
18
+ import core , { AccountUuid , parseSocialIdString , PersonId , type Ref , SocialId , toIdMap } from '@hcengineering/core'
19
19
20
20
export async function getCurrentPerson ( control : TriggerControl ) : Promise < Person | undefined > {
21
21
const { type, value } = parseSocialIdString ( control . txFactory . account )
@@ -81,6 +81,8 @@ export async function getAllSocialStringsByPersonId (
81
81
}
82
82
83
83
export async function getPerson ( control : TriggerControl , personId : PersonId ) : Promise < Person | undefined > {
84
+ if ( personId === core . account . System ) return undefined
85
+
84
86
const { contextData } = control . ctx
85
87
const account : AccountUuid | undefined = contextData . account . socialIds . includes ( personId )
86
88
? contextData . account . uuid
@@ -103,6 +105,8 @@ export async function getPerson (control: TriggerControl, personId: PersonId): P
103
105
}
104
106
105
107
export async function getEmployee ( control : TriggerControl , personId : PersonId ) : Promise < Employee | undefined > {
108
+ if ( personId === core . account . System ) return undefined
109
+
106
110
const socialId = (
107
111
await control . findAll ( control . ctx , contact . class . SocialIdentity , { _id : personId as SocialIdentityRef } )
108
112
) [ 0 ]
0 commit comments