Skip to content

Commit a57065a

Browse files
Alexey PortnovAlexey Portnov
authored andcommitted
fix(mail): voicemail notification missing attachment (#1013)
validate() checked subject/mainMessage before buildVariables() had a chance to set them, causing RuntimeException for VoicemailNotification. The fallback sendDirect() then sent the email without the attachment because it never extracted recordingFile from the builder. - Remove premature subject/mainMessage check from validate() (all builders populate these lazily in buildVariables at render time) - Pass voicemail attachment in sendDirect() fallback path
1 parent 8ccce5f commit a57065a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/Core/System/Mail/Builders/AbstractNotificationBuilder.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,6 @@ public function validate(): void
337337
if (!filter_var($this->recipient, FILTER_VALIDATE_EMAIL)) {
338338
throw new \RuntimeException('Invalid email address: ' . $this->recipient);
339339
}
340-
341-
if (empty($this->subject) && empty($this->mainMessage)) {
342-
throw new \RuntimeException('Either subject or main message must be set');
343-
}
344340
}
345341

346342
/**

src/Core/System/Mail/NotificationQueueHelper.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
use MikoPBX\Core\System\BeanstalkClient;
2424
use MikoPBX\Core\System\Mail\Builders\AbstractNotificationBuilder;
25+
use MikoPBX\Core\System\Mail\Builders\VoicemailNotificationBuilder;
2526
use MikoPBX\Core\System\SystemMessages;
2627
use MikoPBX\Core\Workers\WorkerNotifyByEmail;
2728

@@ -177,8 +178,13 @@ private static function sendDirect(AbstractNotificationBuilder $builder): bool
177178
LOG_INFO
178179
);
179180

181+
$attachmentFile = '';
182+
if ($builder instanceof VoicemailNotificationBuilder) {
183+
$attachmentFile = $builder->getRecordingFile();
184+
}
185+
180186
$service = new EmailNotificationService();
181-
return $service->sendNotification($builder);
187+
return $service->sendNotification($builder, attachmentFile: $attachmentFile);
182188
}
183189

184190
/**

0 commit comments

Comments
 (0)