diff --git a/lang/en/message.php b/lang/en/message.php index 9cced44628c4f..7f178f6649319 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -263,7 +263,7 @@ $string['unreadnewgroupconversationmessage'] = 'New message from {$a->name} in {$a->conversationname}'; $string['unreadnewmessage'] = 'New message from {$a}'; $string['useentertosend'] = 'Use enter to send'; -$string['usercantbemessaged'] = 'You can\'t message {$a} due to their message preferences. Try adding them as a contact.'; +$string['usercantbemessaged'] = 'You can\'t message this user due to their message preferences. Try adding them as a contact.'; $string['userwouldliketocontactyou'] = '{$a} would like to contact you'; $string['viewfullnotification'] = 'View full notification'; $string['viewmessageswith'] = 'View messages with {$a}'; diff --git a/message/externallib.php b/message/externallib.php index a9fe992719e65..57717eded58d8 100644 --- a/message/externallib.php +++ b/message/externallib.php @@ -212,7 +212,7 @@ public static function send_instant_messages($messages = array()) { // Check if the recipient can be messaged by the sender. if ($success && !\core_message\api::can_send_message($tousers[$message['touserid']]->id, $USER->id)) { $success = false; - $errormessage = get_string('usercantbemessaged', 'message', fullname(\core_user::get_user($message['touserid']))); + $errormessage = get_string('usercantbemessaged', 'message'); } // Now we can send the message (at least try). diff --git a/message/tests/externallib_test.php b/message/tests/externallib_test.php index 867ff6d46be7c..832b849140aae 100644 --- a/message/tests/externallib_test.php +++ b/message/tests/externallib_test.php @@ -129,7 +129,7 @@ public function test_send_instant_messages(): void { $sentmessages = core_message_external::send_instant_messages($messages); $sentmessages = external_api::clean_returnvalue(core_message_external::send_instant_messages_returns(), $sentmessages); $this->assertEquals( - get_string('usercantbemessaged', 'message', fullname(\core_user::get_user($message1['touserid']))), + get_string('usercantbemessaged', 'message'), array_pop($sentmessages)['errormessage'] ); @@ -225,7 +225,7 @@ public function test_send_instant_messages_blocked_user(): void { $sentmessage = reset($sentmessages); - $this->assertEquals(get_string('usercantbemessaged', 'message', fullname($user2)), $sentmessage['errormessage']); + $this->assertEquals(get_string('usercantbemessaged', 'message'), $sentmessage['errormessage']); $this->assertEquals(0, $DB->count_records('messages')); } @@ -261,7 +261,7 @@ public function test_send_instant_messages_block_non_contacts(): void { $sentmessage = reset($sentmessages); - $this->assertEquals(get_string('usercantbemessaged', 'message', fullname($user2)), $sentmessage['errormessage']); + $this->assertEquals(get_string('usercantbemessaged', 'message'), $sentmessage['errormessage']); $this->assertEquals(0, $DB->count_records('messages')); }