From 7972d698eda1948f6e8d650fd4bdb202e568dc0c Mon Sep 17 00:00:00 2001 From: Victor Ilyushchenko Date: Tue, 25 Feb 2025 23:26:48 +0300 Subject: [PATCH] Fixed socialId mapping when transcribing (#8096) Signed-off-by: Victor Ilyushchenko --- .../ai-bot/pod-ai-bot/src/workspace/love.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/services/ai-bot/pod-ai-bot/src/workspace/love.ts b/services/ai-bot/pod-ai-bot/src/workspace/love.ts index 8a1e029a71..dc406469a3 100644 --- a/services/ai-bot/pod-ai-bot/src/workspace/love.ts +++ b/services/ai-bot/pod-ai-bot/src/workspace/love.ts @@ -13,6 +13,8 @@ // limitations under the License. // import { ConnectMeetingRequest } from '@hcengineering/ai-bot' +import chunter from '@hcengineering/chunter' +import contact, { Person, pickPrimarySocialId } from '@hcengineering/contact' import core, { concatLink, Doc, @@ -20,7 +22,6 @@ import core, { MeasureContext, PersonId, Ref, - SocialIdType, TxCreateDoc, TxCUD, TxOperations, @@ -28,7 +29,6 @@ import core, { TxUpdateDoc, WorkspaceUuid } from '@hcengineering/core' -import contact, { Person } from '@hcengineering/contact' import love, { getFreeRoomPlace, MeetingMinutes, @@ -39,7 +39,6 @@ import love, { TranscriptionStatus } from '@hcengineering/love' import { jsonToMarkup, MarkupNodeType } from '@hcengineering/text' -import chunter from '@hcengineering/chunter' import config from '../config' @@ -174,16 +173,18 @@ export class LoveController { } async getSocialId (person: Ref): Promise { - const socialId = - this.socialIdByPerson.get(person) ?? - ( - await this.client.findOne(contact.class.SocialIdentity, { - attachedTo: person, - attachedToClass: contact.class.Person, - type: SocialIdType.HULY - }) - )?.key + if (!this.socialIdByPerson.has(person)) { + const identities = await this.client.findAll(contact.class.SocialIdentity, { + attachedTo: person, + attachedToClass: contact.class.Person + }) + if (identities.length > 0) { + const id = pickPrimarySocialId(identities.map((si) => si.key)) + this.socialIdByPerson.set(person, id) + } + } + const socialId = this.socialIdByPerson.get(person) if (socialId === undefined) { return }