- jobs/MailJob->sendAllMessageEmailNotices changed since parameter default value

- Moved ALT_OE from MessageLib to CL/Messages_model
- MessageLib->_setSentError renamed to _updatedRecipientNoticeEmailInfo
- MessageLib->_sendNoticeEmail changed to have more information about a not sent notice email
- Recipient_model->getNotSentMessages now does not retrieve messages with notice email send failure
This commit is contained in:
Paolo
2020-02-25 16:41:27 +01:00
parent b9d973a6e8
commit a50cc6cba8
4 changed files with 33 additions and 10 deletions
+26 -7
View File
@@ -26,8 +26,6 @@ class MessageLib
const EMAIL_KONTAKT_TYPE = 'email'; // Email kontakt type
const SENT_INFO_NEWLINE = '\n'; // tbl_msg_recipient->sentInfo separator
const ALT_OE = 'infocenter'; // alternative organisation unit when no one is found for a presetudent
private $_ci;
/**
@@ -498,7 +496,7 @@ class MessageLib
* Stores the type of error in 'sentinfo' column keeping en eventual previous error
* sent column is set to null
*/
private function _setSentError($message_id, $receiver_id, $sentInfo, $prevSentInfo)
private function _updatedRecipientNoticeEmailInfo($message_id, $receiver_id, $sentInfo, $prevSentInfo)
{
if (!isEmptyString($prevSentInfo))
{
@@ -763,15 +761,15 @@ class MessageLib
if (!$sent)
{
// Set in database why this email is NOT going to be send
$sse = $this->_setSentError(
$sse = $this->_updatedRecipientNoticeEmailInfo(
$messageData->message_id,
$messageData->receiver_id,
'An error occurred while sending the notice email',
$messageData->sentinfo
'An error occurred while sending the notice email', // current info
$messageData->sentinfo // previous info
);
// If database error occurred then return it, otherwise return a logic error
return isError($sse) ? $sse : error('An error occurred while sending the notice email');
return isError($sse) ? $sse : error('An error occurred while updating the recipient notice email info');
}
else // success!
{
@@ -780,6 +778,27 @@ class MessageLib
if (isError($sss)) return $sss; // If database error occurred then return it
}
}
else // Because was not possible to find a valid contact
{
$reason = 'Was not possible to find a valid contact for this user'; // default reason
// In case that the organisation unit does not receive any email notices
if (!isEmptyString($messageData->receiver_ou)) $reason = 'This organization unit does not receive email notices';
// In case that a degree program sent a message to a user without a valid contact or UID
if (!isEmptyString($messageData->sender_ou)) $reason = 'Sent from a degree program to a user that does not have a valid UID or a valid contact';
// Set in database why this email is NOT going to be send
$sse = $this->_updatedRecipientNoticeEmailInfo(
$messageData->message_id,
$messageData->receiver_id,
$reason, // current info
$messageData->sentinfo // previous info
);
// If database error occurred then return it
if (isError($sse)) return $sse;
}
}
return success('Notice emails sent successfully');