Skip to content
Snippets Groups Projects
Commit 63191915 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #17150 TIME 0:35 user notification preference can be a list

parent 0132182b
No related branches found
No related tags found
No related merge requests found
......@@ -235,14 +235,15 @@ class EmailController
$recipient['preferences'] = json_decode($recipient['preferences'], true);
$args['recipient'] = ['lang' => $recipient['preferences']['lang'], 'email' => $recipient['email']];
if ($recipient['preferences']['notifications'] == 'summary') {
NotificationStackModel::create([ // TODO save workflow id ? -> to prevent sending notif after doc processed by user
if (in_array('summary', $recipient['preferences']['notifications'])) {
NotificationStackModel::create([
'mainDocumentId' => $args['documentId'],
'type' => 'typist_' . $args['mode'],
'senderId' => $args['senderId'],
'recipientId' => $args['recipientId']
]);
} elseif ($recipient['preferences']['notifications'] == 'instant' && $recipient['isRest'] == false) {
}
if (in_array('instant', $recipient['preferences']['notifications']) && $recipient['isRest'] == false) {
EmailController::sendNotificationToTypist($args);
}
}
......@@ -283,28 +284,30 @@ class EmailController
{
$nextUser = UserModel::getById(['select' => ['email', 'preferences', 'substitute'], 'id' => $args['recipientId']]);
$nextUser['preferences'] = json_decode($nextUser['preferences'], true);
if ($nextUser['preferences']['notifications'] == 'summary') {
if (in_array('summary', $nextUser['preferences']['notifications'])) {
NotificationStackModel::create([
'mainDocumentId' => $args['documentId'],
'type' => 'next_user',
'senderId' => $args['senderId'],
'recipientId' => $args['recipientId']
]);
} else if ($nextUser['preferences']['notifications'] == 'instant') {
}
if (in_array('instant', $nextUser['preferences']['notifications'])) {
EmailController::sendNotificationToUser(['documentId' => $args['documentId'], 'senderId' => $args['senderId'], 'email' => $nextUser['email'], 'preferences' => $nextUser['preferences']]);
}
if (!empty($nextUser['substitute'])) {
$nextSubstituteUser = UserModel::getById(['select' => ['email', 'preferences'], 'id' => $nextUser['substitute']]);
$nextSubstituteUser['preferences'] = json_decode($nextSubstituteUser['preferences'], true);
if ($nextSubstituteUser['preferences']['notifications'] == 'summary') {
if (in_array('summary', $nextSubstituteUser['preferences']['notifications'])) {
NotificationStackModel::create([
'mainDocumentId' => $args['documentId'],
'type' => 'next_user',
'senderId' => $args['senderId'],
'recipientId' => $nextUser['substitute']
]);
} else if ($nextUser['preferences']['notifications'] == 'instant') {
}
if (in_array('instant', $nextSubstituteUser['preferences']['notifications'])) {
EmailController::sendNotificationToUser(['documentId' => $args['documentId'], 'senderId' => $args['senderId'], 'email' => $nextSubstituteUser['email'], 'preferences' => $nextSubstituteUser['preferences']]);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment