From cd1f3242db952881027f3a8fd619e9ddad92d7be Mon Sep 17 00:00:00 2001 From: XavierGR Date: Mon, 18 Nov 2024 10:49:56 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B07726=20-=20Fatal=20error=20if=20a=20news?= =?UTF-8?q?room=20is=20sent=20without=20any=20message=20Handle=20async=20E?= =?UTF-8?q?ventNewsroom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/datamodel.core.xml | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/core/datamodel.core.xml b/core/datamodel.core.xml index bea18700c..9e599eb2b 100644 --- a/core/datamodel.core.xml +++ b/core/datamodel.core.xml @@ -355,20 +355,30 @@ } } - if ($bIsAsync === true) { - AsyncSendNewsroom::AddToQueue($this->GetKey(), $oTrigger->GetKey(), $aRecipientsIds, $sMessage, $sTitle, $sUrl, $iObjectId, $sObjectClass); - } else { - foreach ($aRecipientsIds as $iRecipientId) { - $oEvent = Combodo\iTop\Service\Notification\Event\EventNotificationNewsroomService::MakeEventFromAction($this, $iRecipientId, $oTrigger->GetKey(), $sMessage, $sTitle, $sUrl, $iObjectId, $sObjectClass); - try { - $oEvent->DBInsertNoReload(); - } catch(CoreCannotSaveObjectException $e) { - ExceptionLog::LogException($e); - $oEvent = Combodo\iTop\Service\Notification\Event\EventNotificationNewsroomService::MakeEventFromAction($this, $iRecipientId, $oTrigger->GetKey(), Dict::Format('Core:EventNotificationNewsroom:ErrorOnDBInsert'), Dict::Format('Core:EventNotificationNewsroom:ErrorNotificationNotSent'), $sUrl, $iObjectId, $sObjectClass); - $oEvent->DBInsertNoReload(); - } - } - } + try { + if ($bIsAsync === true) { + AsyncSendNewsroom::AddToQueue($this->GetKey(), $oTrigger->GetKey(), $aRecipientsIds, $sMessage, $sTitle, $sUrl, $iObjectId, $sObjectClass); + } else { + foreach ($aRecipientsIds as $iRecipientId) { + $oEvent = Combodo\iTop\Service\Notification\Event\EventNotificationNewsroomService::MakeEventFromAction($this, $iRecipientId, $oTrigger->GetKey(), $sMessage, $sTitle, $sUrl, $iObjectId, $sObjectClass); + $oEvent->DBInsertNoReload(); + } + } + } catch (CoreCannotSaveObjectException $e) { + ExceptionLog::LogException($e); + foreach($aRecipientsIds as $iRecipientId) { + $oEvent = Combodo\iTop\Service\Notification\Event\EventNotificationNewsroomService::MakeEventFromAction($this, + $iRecipientId, + $oTrigger->GetKey(), + Dict::S('Core:EventNotificationNewsroom:ErrorOnDBInsert'), + Dict::S('Core:EventNotificationNewsroom:ErrorNotificationNotSent'), + $sUrl, + $iObjectId, + $sObjectClass + ); + $oEvent->DBInsertNoReload(); + } + } $this->SetNotificationLanguage($sPreviousLanguage, $aPreviousPluginProperties['language_code'] ?? null); }