From 36f5340b8235dc80477427beabbbb9ff18f2abc1 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tumanov Date: Wed, 22 Nov 2023 20:32:30 +0500 Subject: [PATCH] UBER-636: fix from&to for NewMessage (#4043) Signed-off-by: Vyacheslav Tumanov --- plugins/gmail-resources/src/utils.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/gmail-resources/src/utils.ts b/plugins/gmail-resources/src/utils.ts index 63fad146a1..d6d5dfce1d 100644 --- a/plugins/gmail-resources/src/utils.ts +++ b/plugins/gmail-resources/src/utils.ts @@ -8,6 +8,7 @@ import contact, { import { type Doc, type IdMap, type Ref, toIdMap } from '@hcengineering/core' import { type Message, type SharedMessage } from '@hcengineering/gmail' import { getClient } from '@hcengineering/presentation' +import gmail from './plugin' export function getTime (time: number): string { let options: Intl.DateTimeFormatOptions = { hour: 'numeric', minute: 'numeric' } @@ -109,6 +110,14 @@ export function getName ( sender: boolean ): string { const h = getClient().getHierarchy() + if (message._class === gmail.class.NewMessage) { + if (!sender) return `${getContactName(h, object)} (${channel.value})` + const account = accounts.get(message.modifiedBy as Ref) + const emp = account != null ? employees.get(account?.person as Ref) : undefined + const email = account?.email + const from = accounts.get(message.from as Ref)?.email ?? message.from + return emp != null ? `${getContactName(h, emp)} (${email})` : from + } if (message.incoming === sender) { return `${getContactName(h, object)} (${channel.value})` } else {