From 66e7a118d494b0ccee90a308bb5c46a6b4cf8d67 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 24 Jun 2024 13:58:20 +1200 Subject: [PATCH] NEW Send an email notification when a job is broken --- src/Services/EmailService.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Services/EmailService.php b/src/Services/EmailService.php index 0aae9d19..e373cc17 100644 --- a/src/Services/EmailService.php +++ b/src/Services/EmailService.php @@ -6,7 +6,6 @@ use SilverStripe\Control\Email\Email; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Injector\Injectable; -use SilverStripe\Subsites\Model\Subsite; /** * Class EmailService @@ -35,11 +34,6 @@ public function __construct() ); } - /** - * @param array $jobConfig - * @param string $title - * @return Email|null - */ public function createMissingDefaultJobReport(array $jobConfig, string $title): ?Email { $subject = sprintf('Default Job "%s" missing', $title); @@ -59,12 +53,6 @@ public function createMissingDefaultJobReport(array $jobConfig, string $title): ->setHTMLTemplate('QueuedJobsDefaultJob'); } - /** - * @param string $subject - * @param string $message - * @param int $jobID - * @return Email|null - */ public function createStalledJobReport(string $subject, string $message, int $jobID): ?Email { $email = $this->createReport($subject); @@ -81,12 +69,18 @@ public function createStalledJobReport(string $subject, string $message, int $jo ->setHTMLTemplate('QueuedJobsStalledJob'); } + public function createBrokenJobReport(string $subject, string $message): ?Email + { + $email = $this->createReport($subject); + if ($email === null) { + return null; + } + return $email->text($message); + } + /** * Create a generic email report * useful for reporting queue service issues - * - * @param string $subject - * @return Email|null */ public function createReport(string $subject): ?Email {