From 5933ca81d54e94a3dc0e21e794dab2b12ed81748 Mon Sep 17 00:00:00 2001
From: Alexander Onnikov <Alexander.Onnikov@gmail.com>
Date: Wed, 16 Aug 2023 13:27:50 +0700
Subject: [PATCH] UBER-741 Fix collaborators logic (#3594)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
---
 server-plugins/notification-resources/src/index.ts | 4 ++--
 server-plugins/notification/src/index.ts           | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/server-plugins/notification-resources/src/index.ts b/server-plugins/notification-resources/src/index.ts
index 0db66810e4..f21c385daa 100644
--- a/server-plugins/notification-resources/src/index.ts
+++ b/server-plugins/notification-resources/src/index.ts
@@ -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] }
         })
diff --git a/server-plugins/notification/src/index.ts b/server-plugins/notification/src/index.ts
index b7359757cc..b1062965ff 100644
--- a/server-plugins/notification/src/index.ts
+++ b/server-plugins/notification/src/index.ts
@@ -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 }
     )