feat(talk): replace text type prefixes with emojis in messages

- Extract `typeIcon` from mapped data in `WebhookController` and pass to `prependDisplayName`
- Update `TalkService.prependDisplayName` to accept optional `$typeIcon` parameter and prepend it to the display name line
- Remove text-based type labels (`[Info]`, `[Success]`, `[Warning]`, `[Error]`) and replace with emoji icons (``, `⚠️`, ``)
- Include `typeIcon` in the message payload array returned by `TalkService`
This commit is contained in:
kyle
2026-06-14 00:21:48 -07:00
parent 7b14ecbcbb
commit 5347ddcdb0
2 changed files with 18 additions and 16 deletions
+16 -15
View File
@@ -598,8 +598,9 @@ class TalkService {
* Prepend a display name line to a message.
* Since Talk doesn't support per-message avatars, we embed the name in the message.
*/
public function prependDisplayName(string $displayName, string $message): string {
$nameLine = '🤖 **' . $displayName . '**';
public function prependDisplayName(string $displayName, string $message, string $typeIcon = ''): string {
$icon = $typeIcon !== '' ? $typeIcon . ' ' : '';
$nameLine = $icon . '🤖 **' . $displayName . '**';
if ($message === '') {
return $nameLine;
}
@@ -752,23 +753,11 @@ class TalkService {
'senderName' => $senderName,
'displayName' => $displayName,
'richObjects' => $richObjects,
'typeIcon' => '',
];
}
}
// Type prefix for context (e.g. "[Warning]")
if (!empty($data['type'])) {
$typeLabels = [
'info' => '[Info]',
'success' => '[Success]',
'warning' => '[Warning]',
'error' => '[Error]',
];
if (isset($typeLabels[$data['type']])) {
array_unshift($parts, $typeLabels[$data['type']]);
}
}
$message = implode("\n\n", $parts);
// If body is empty but we have a title/subject, use it as the message
@@ -882,11 +871,23 @@ class TalkService {
}
}
// Determine type icon for the sender line (empty for info/image)
$typeIcon = '';
if (!empty($data['type'])) {
$typeIcons = [
'success' => '✅',
'warning' => '⚠️',
'error' => '❌',
];
$typeIcon = $typeIcons[$data['type']] ?? '';
}
return [
'message' => $message,
'senderName' => $senderName,
'displayName' => $displayName,
'richObjects' => $richObjects,
'typeIcon' => $typeIcon,
];
}