MDL-68070 messaging: Ensure that error is shown on first messages

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.
This commit is contained in:
Eloy Lafuente (stronk7)
2020-10-14 18:58:00 +02:00
committed by Sara Arjona
parent 2020abe0d8
commit 9fad671e5d
+3
View File
@@ -215,6 +215,9 @@ class core_message_external extends external_api {
// 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;
}