mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 09:51:53 +00:00
Fix mentions and threads (#8309)
This commit is contained in:
parent
a343075411
commit
e70c86f86f
@ -296,13 +296,15 @@ export function includesAny (members: PersonId[], ids: PersonId[]): boolean {
|
||||
|
||||
export async function getPersonBySocialKey (client: Client, socialKey: string): Promise<Person | undefined> {
|
||||
const socialId = await client.findOne(contact.class.SocialIdentity, { key: socialKey })
|
||||
|
||||
if (socialId === undefined) return undefined
|
||||
return await client.findOne(contact.class.Person, { _id: socialId?.attachedTo, _class: socialId?.attachedToClass })
|
||||
}
|
||||
|
||||
export async function getPersonBySocialId (client: Client, socialIdString: PersonId): Promise<Person | undefined> {
|
||||
const socialId = await client.findOne(contact.class.SocialIdentity, { _id: socialIdString as SocialIdentityRef })
|
||||
|
||||
if (socialId === undefined) return undefined
|
||||
|
||||
return await client.findOne(contact.class.Person, { _id: socialId?.attachedTo, _class: socialId?.attachedToClass })
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ import core, {
|
||||
Data,
|
||||
Doc,
|
||||
generateId,
|
||||
parseSocialIdString,
|
||||
Hierarchy,
|
||||
Markup,
|
||||
Ref,
|
||||
@ -40,6 +39,7 @@ import core, {
|
||||
AccountUuid
|
||||
} from '@hcengineering/core'
|
||||
import notification, { CommonInboxNotification, MentionInboxNotification } from '@hcengineering/notification'
|
||||
import { getPerson } from '@hcengineering/server-contact'
|
||||
import { StorageAdapter, TriggerControl } from '@hcengineering/server-core'
|
||||
import {
|
||||
applyNotificationProviders,
|
||||
@ -155,15 +155,11 @@ export async function getPersonNotificationTxes (
|
||||
archived: false
|
||||
}
|
||||
|
||||
const { type, value } = parseSocialIdString(senderId)
|
||||
|
||||
const senderSocialIds = await control.findAll(ctx, contact.class.SocialIdentity, { type, value })
|
||||
const senderSocialId = senderSocialIds[0]
|
||||
|
||||
const senderPerson =
|
||||
senderId !== undefined
|
||||
? (await control.findAll(ctx, contact.class.Person, { _id: senderSocialId.attachedTo }, { limit: 1 }))[0]
|
||||
: undefined
|
||||
const senderPerson = await getPerson(control, senderId)
|
||||
const senderSocialIds =
|
||||
senderPerson !== undefined
|
||||
? await control.findAll(ctx, contact.class.SocialIdentity, { attachedTo: senderPerson._id })
|
||||
: []
|
||||
|
||||
const receiverSocialString = pickPrimarySocialId(receiverSocialStrings)
|
||||
const receiverInfo = toReceiverInfo(control.hierarchy, {
|
||||
|
@ -137,7 +137,7 @@ async function OnThreadMessageCreated (originTx: TxCUD<Doc>, control: TriggerCon
|
||||
|
||||
const person = await getPerson(control, originTx.modifiedBy)
|
||||
if (person === undefined) {
|
||||
return []
|
||||
return [lastReplyTx]
|
||||
}
|
||||
|
||||
if ((message.repliedPersons ?? []).includes(person._id)) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
//
|
||||
|
||||
import { TriggerControl } from '@hcengineering/server-core'
|
||||
import contact, { Employee, pickPrimarySocialId, SocialIdentityRef, type Person } from '@hcengineering/contact'
|
||||
import contact, { Employee, type Person, pickPrimarySocialId, SocialIdentityRef } from '@hcengineering/contact'
|
||||
import { AccountUuid, parseSocialIdString, PersonId, type Ref, toIdMap } from '@hcengineering/core'
|
||||
|
||||
export async function getCurrentPerson (control: TriggerControl): Promise<Person | undefined> {
|
||||
@ -25,14 +25,12 @@ export async function getCurrentPerson (control: TriggerControl): Promise<Person
|
||||
return undefined
|
||||
}
|
||||
|
||||
const person = (
|
||||
return (
|
||||
await control.findAll(control.ctx, contact.class.Person, {
|
||||
_id: socialIdentity.attachedTo,
|
||||
_class: socialIdentity.attachedToClass
|
||||
})
|
||||
)[0]
|
||||
|
||||
return person
|
||||
}
|
||||
|
||||
export async function getSocialStrings (control: TriggerControl, person: Ref<Person>): Promise<PersonId[]> {
|
||||
@ -119,7 +117,13 @@ export async function getEmployee (control: TriggerControl, personId: PersonId):
|
||||
const socialId = (
|
||||
await control.findAll(control.ctx, contact.class.SocialIdentity, { _id: personId as SocialIdentityRef })
|
||||
)[0]
|
||||
const employee = (
|
||||
|
||||
if (socialId === undefined) {
|
||||
control.ctx.error('Cannot find social id', { _id: personId })
|
||||
return undefined
|
||||
}
|
||||
|
||||
return (
|
||||
await control.findAll(
|
||||
control.ctx,
|
||||
contact.mixin.Employee,
|
||||
@ -127,8 +131,6 @@ export async function getEmployee (control: TriggerControl, personId: PersonId):
|
||||
{ limit: 1 }
|
||||
)
|
||||
)[0]
|
||||
|
||||
return employee
|
||||
}
|
||||
|
||||
export async function getEmployeeByAcc (control: TriggerControl, account: AccountUuid): Promise<Employee | undefined> {
|
||||
@ -136,11 +138,9 @@ export async function getEmployeeByAcc (control: TriggerControl, account: Accoun
|
||||
}
|
||||
|
||||
export async function getEmployees (control: TriggerControl, accounts: AccountUuid[]): Promise<Employee[]> {
|
||||
const employees = await control.findAll(control.ctx, contact.mixin.Employee, {
|
||||
return await control.findAll(control.ctx, contact.mixin.Employee, {
|
||||
personUuid: { $in: accounts }
|
||||
})
|
||||
|
||||
return employees
|
||||
}
|
||||
|
||||
export async function getEmployeesBySocialIds (
|
||||
|
Loading…
Reference in New Issue
Block a user