From 98e044ede76ca50b3d5dbdb1e094d140d610e6be Mon Sep 17 00:00:00 2001 From: kyle Date: Fri, 12 Jun 2026 17:53:30 -0700 Subject: [PATCH] feat: improve Apprise notification subject/title handling and fallbacks - lib/Controller/WebhookController.php: Extract subject/title from wrapper level and add fallback to default sender name - lib/Service/TalkService.php: Update display name logic to check subject, and use title/subject as message body when empty --- lib/Controller/WebhookController.php | 13 +++++++++++++ lib/Service/TalkService.php | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/Controller/WebhookController.php b/lib/Controller/WebhookController.php index 6f54bbc..adc8b66 100644 --- a/lib/Controller/WebhookController.php +++ b/lib/Controller/WebhookController.php @@ -233,7 +233,20 @@ class WebhookController extends Controller { // Apprise API wraps notifications in a "notifications" array if (isset($data['notifications']) && is_array($data['notifications']) && !empty($data['notifications'])) { + $wrapper = $data; $data = $data['notifications'][0]; + // Some Apprise versions put subject/title at the wrapper level + if (empty($data['subject']) && !empty($wrapper['subject'])) { + $data['subject'] = $wrapper['subject']; + } + if (empty($data['title']) && !empty($wrapper['title'])) { + $data['title'] = $wrapper['title']; + } + } + + // Fallback: if no subject/title anywhere, use config default + if (empty($data['subject']) && empty($data['title'])) { + $data['subject'] = $this->talkService->getSenderNameDefault(); } // Map apprise format to our internal payload format diff --git a/lib/Service/TalkService.php b/lib/Service/TalkService.php index 21b5541..47280fd 100644 --- a/lib/Service/TalkService.php +++ b/lib/Service/TalkService.php @@ -587,8 +587,10 @@ class TalkService { public function mapApprisePayload(array $data, string $roomToken = ''): array { $parts = []; - // Display name: use Apprise title (source/app name) as the display name - $displayName = !empty($data['title']) ? $data['title'] : $this->config->getAppValue(self::APP_ID, 'sender_name', 'Webhook Bot'); + // Display name: use Apprise title/subject (source/app name) as the display name + $displayName = !empty($data['title']) ? $data['title'] + : (!empty($data['subject']) ? $data['subject'] + : $this->config->getAppValue(self::APP_ID, 'sender_name', 'Webhook Bot')); // Body if (!empty($data['body'])) { @@ -658,6 +660,16 @@ class TalkService { $message = implode("\n\n", $parts); + // If body is empty but we have a title/subject, use it as the message + // (handles test notifications and simple alerts with no body) + if ($message === '') { + if (!empty($data['title'])) { + $message = $data['title']; + } elseif (!empty($data['subject'])) { + $message = $data['subject']; + } + } + // Sender name: use app name if available, otherwise default $senderName = $displayName;