Skip to content

Commit

Permalink
MDL-68070 messaging: Ensure that error is shown on first messages
Browse files Browse the repository at this point in the history
Before there is a conversation, messages between users are sent
using core_message_send_instant_messages instead of
core_message_send_messages_to_conversation.

That method had an undefined $errormessage variable, ultimately
causing the problem detected on message_post_message()/message_send()
to never been returned by the external.

This just adds the same error than already existing conversations do,
but returning it as warning, for BC, JS will show it.
  • Loading branch information
stronk7 authored and sarjona committed Oct 14, 2020
1 parent d82acd3 commit f68a64d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions message/externallib.php
Expand Up @@ -215,6 +215,9 @@ public static function send_instant_messages($messages = array()) {
// We should have thrown exceptions as these errors prevent results to be returned.
// See http://docs.moodle.org/dev/Errors_handling_in_web_services#When_to_send_a_warning_on_the_server_side .
$resultmsg['msgid'] = -1;
if (!isset($errormessage)) { // Nobody has set a message error or thrown an exception, let's set it.
$errormessage = get_string('messageundeliveredbynotificationsettings', 'error');
}
$resultmsg['errormessage'] = $errormessage;
}

Expand Down

0 comments on commit f68a64d

Please sign in to comment.