Skip to content

Commit

Permalink
MDL-57755 message: fix notificaiton read status when messaging disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
t-schroeder committed Jan 27, 2020
1 parent 77a359c commit 6fd48ef
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions lib/classes/message/manager.php
Expand Up @@ -331,15 +331,14 @@ public static function send_message(message $eventdata, \stdClass $savemessage,
// Trigger event for sending a message or notification - we need to do this before marking as read!
self::trigger_message_events($eventdata, $savemessage);

if ($eventdata->notification or empty($CFG->messaging)) {
// If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
// The same goes if the messaging is completely disabled.
if ($eventdata->notification) {
$savemessage->timeread = null;
\core_message\api::mark_notification_as_read($savemessage);
} else {
\core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
}
if ($eventdata->notification) {
// If they have deselected all processors and it's a notification mark it read. The user doesn't want to be
// bothered.
$savemessage->timeread = null;
\core_message\api::mark_notification_as_read($savemessage);
} else if (empty($CFG->messaging)) {
// If it's a message and messaging is disabled mark it read.
\core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
}

return $savemessage->id;
Expand Down Expand Up @@ -383,15 +382,9 @@ protected static function send_message_to_processors($eventdata, \stdClass $save
// Trigger event for sending a message or notification - we need to do this before marking as read!
self::trigger_message_events($eventdata, $savemessage);

if (empty($CFG->messaging)) {
// If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
// The same goes if the messaging is completely disabled.
if ($eventdata->notification) {
$savemessage->timeread = null;
\core_message\api::mark_notification_as_read($savemessage);
} else {
\core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
}
if (!$eventdata->notification && empty($CFG->messaging)) {
// If it's a message and messaging is disabled mark it read.
\core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
}

return $savemessage->id;
Expand Down

0 comments on commit 6fd48ef

Please sign in to comment.