UBER-741 Fix collaborators logic (#3594)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2023-08-16 13:27:50 +07:00 committed by GitHub
parent cdba698d2a
commit 5933ca81d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -279,7 +279,7 @@ async function getValueCollaborators (value: any, attr: AnyAttribute, control: T
const hierarchy = control.hierarchy
if (attr.type._class === core.class.RefTo) {
const to = (attr.type as RefTo<Doc>).to
if (hierarchy.isDerived(to, contact.mixin.Employee)) {
if (hierarchy.isDerived(to, contact.class.Person)) {
const acc = await getPersonAccount(value, control)
return acc !== undefined ? [acc._id] : []
} else if (hierarchy.isDerived(to, core.class.Account)) {
@ -290,7 +290,7 @@ async function getValueCollaborators (value: any, attr: AnyAttribute, control: T
const arrOf = (attr.type as ArrOf<RefTo<Doc>>).of
if (arrOf._class === core.class.RefTo) {
const to = (arrOf as RefTo<Doc>).to
if (hierarchy.isDerived(to, contact.mixin.Employee)) {
if (hierarchy.isDerived(to, contact.class.Person)) {
const employeeAccounts = await control.modelDb.findAll(contact.class.PersonAccount, {
person: { $in: Array.isArray(value) ? value : [value] }
})

View File

@ -1,6 +1,6 @@
//
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021, 2022 Hardcore Engineering Inc.
// Copyright © 2021, 2022, 2023 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
@ -14,7 +14,7 @@
// limitations under the License.
//
import contact, { Employee, PersonAccount } from '@hcengineering/contact'
import contact, { Employee, Person, PersonAccount } from '@hcengineering/contact'
import { Account, Class, Doc, Mixin, Ref, Tx } from '@hcengineering/core'
import { NotificationType } from '@hcengineering/notification'
import { Plugin, Resource, plugin } from '@hcengineering/platform'
@ -29,14 +29,14 @@ export const serverNotificationId = 'server-notification' as Plugin
* @public
*/
export async function getPersonAccount (
employee: Ref<Employee>,
person: Ref<Person>,
control: TriggerControl
): Promise<PersonAccount | undefined> {
const account = (
await control.modelDb.findAll(
contact.class.PersonAccount,
{
employee
person
},
{ limit: 1 }
)