From cbc2a3b31b5b6c138cd9ed123959950c9f1fd630 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Mon, 23 Feb 2026 08:10:59 +0700 Subject: [PATCH] Fallback Telegram avatars from identities in dashboard --- frontend/server/graphql/schema.ts | 32 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/frontend/server/graphql/schema.ts b/frontend/server/graphql/schema.ts index 6ea0650..33fefd8 100644 --- a/frontend/server/graphql/schema.ts +++ b/frontend/server/graphql/schema.ts @@ -312,6 +312,7 @@ async function getDashboard(auth: AuthContext | null) { include: { note: { select: { content: true } }, messages: { select: { occurredAt: true }, orderBy: { occurredAt: "desc" }, take: 1 }, + omniIdentities: { select: { channel: true, externalId: true } }, }, orderBy: { updatedAt: "desc" }, take: 500, @@ -364,17 +365,26 @@ async function getDashboard(auth: AuthContext | null) { channelsByContactId.get(item.contactId)?.add(mapChannel(item.channel)); } - const contacts = contactsRaw.map((c) => ({ - id: c.id, - name: c.name, - avatar: c.avatarUrl ?? "", - company: c.company ?? "", - country: c.country ?? "", - location: c.location ?? "", - channels: Array.from(channelsByContactId.get(c.id) ?? []), - lastContactAt: c.messages[0]?.occurredAt?.toISOString?.() ?? c.updatedAt.toISOString(), - description: c.note?.content ?? "", - })); + const contacts = contactsRaw.map((c) => { + const telegramIdentity = c.omniIdentities.find( + (identity) => identity.channel === "TELEGRAM" && /^\d+$/.test(identity.externalId), + ); + const avatar = + (c.avatarUrl ?? "").trim() || + (telegramIdentity ? `/api/omni/telegram/avatar/${telegramIdentity.externalId}` : ""); + + return { + id: c.id, + name: c.name, + avatar, + company: c.company ?? "", + country: c.country ?? "", + location: c.location ?? "", + channels: Array.from(channelsByContactId.get(c.id) ?? []), + lastContactAt: c.messages[0]?.occurredAt?.toISOString?.() ?? c.updatedAt.toISOString(), + description: c.note?.content ?? "", + }; + }); const communications = communicationsRaw.map((m) => ({ id: m.id,