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:
@@ -473,7 +473,8 @@ class WebhookController extends Controller {
|
|||||||
|
|
||||||
// Prepend display name since Talk doesn't support per-message avatars
|
// Prepend display name since Talk doesn't support per-message avatars
|
||||||
$displayName = $mapped['displayName'] ?? $senderName;
|
$displayName = $mapped['displayName'] ?? $senderName;
|
||||||
$message = $this->talkService->prependDisplayName($displayName, $mapped['message']);
|
$typeIcon = $mapped['typeIcon'] ?? '';
|
||||||
|
$message = $this->talkService->prependDisplayName($displayName, $mapped['message'], $typeIcon);
|
||||||
|
|
||||||
// Post to Talk via Chat API
|
// Post to Talk via Chat API
|
||||||
$success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects);
|
$success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects);
|
||||||
|
|||||||
+16
-15
@@ -598,8 +598,9 @@ class TalkService {
|
|||||||
* Prepend a display name line to a message.
|
* Prepend a display name line to a message.
|
||||||
* Since Talk doesn't support per-message avatars, we embed the name in the message.
|
* Since Talk doesn't support per-message avatars, we embed the name in the message.
|
||||||
*/
|
*/
|
||||||
public function prependDisplayName(string $displayName, string $message): string {
|
public function prependDisplayName(string $displayName, string $message, string $typeIcon = ''): string {
|
||||||
$nameLine = '🤖 **' . $displayName . '**';
|
$icon = $typeIcon !== '' ? $typeIcon . ' ' : '';
|
||||||
|
$nameLine = $icon . '🤖 **' . $displayName . '**';
|
||||||
if ($message === '') {
|
if ($message === '') {
|
||||||
return $nameLine;
|
return $nameLine;
|
||||||
}
|
}
|
||||||
@@ -752,23 +753,11 @@ class TalkService {
|
|||||||
'senderName' => $senderName,
|
'senderName' => $senderName,
|
||||||
'displayName' => $displayName,
|
'displayName' => $displayName,
|
||||||
'richObjects' => $richObjects,
|
'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);
|
$message = implode("\n\n", $parts);
|
||||||
|
|
||||||
// If body is empty but we have a title/subject, use it as the message
|
// 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 [
|
return [
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'senderName' => $senderName,
|
'senderName' => $senderName,
|
||||||
'displayName' => $displayName,
|
'displayName' => $displayName,
|
||||||
'richObjects' => $richObjects,
|
'richObjects' => $richObjects,
|
||||||
|
'typeIcon' => $typeIcon,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user