( user: PlatformUser | undefined, platform: string, )
| 10 | * Telegram, and WhatsApp alike. |
| 11 | */ |
| 12 | export function senderContext( |
| 13 | user: PlatformUser | undefined, |
| 14 | platform: string, |
| 15 | ): ContextEntry[] { |
| 16 | // `createBot` substitutes `{ id: "" }` for an unresolved sender (a truthy |
| 17 | // object), so guard on a usable id — not mere object presence — otherwise we |
| 18 | // emit a "Requesting <platform> user (... id )" entry with nothing to attribute. |
| 19 | if (!user?.id) return []; |
| 20 | const label = `${user.name ?? user.id}${user.email ? ` <${user.email}>` : ""} (${platform} id ${user.id})`; |
| 21 | return [{ description: `Requesting ${platform} user`, value: label }]; |
| 22 | } |
no outgoing calls
no test coverage detected