Merge branch 'MDL-81685_matrix_homeserver_name_main' of https://github.com/mark-webster-catalyst/moodle
This commit is contained in:
@@ -67,7 +67,12 @@ class matrix_user_manager {
|
||||
$username = self::MATRIX_USER_PREFIX . $username;
|
||||
}
|
||||
|
||||
$homeserver = self::get_formatted_matrix_home_server();
|
||||
$homeserver = get_config('communication_matrix', 'matrixhomeservername');
|
||||
|
||||
// Fall back to homeserver URL if name not set.
|
||||
if (empty($homeserver)) {
|
||||
$homeserver = self::get_formatted_matrix_home_server();
|
||||
}
|
||||
|
||||
return "@{$username}:{$homeserver}";
|
||||
}
|
||||
|
||||
@@ -23,14 +23,16 @@
|
||||
*/
|
||||
|
||||
$string['cachedef_serverversions'] = 'Matrix server version information for running servers';
|
||||
$string['matrixuserid'] = 'Matrix user ID';
|
||||
$string['matrixhomeservername'] = 'Homeserver Name';
|
||||
$string['matrixhomeservername_desc'] = 'The part after <code>@user:</code> in your Matrix ID (e.g. <code>example.com</code> in <code>@user:example.com</code>)';
|
||||
$string['matrixhomeserverurl'] = 'Homeserver URL';
|
||||
$string['matrixhomeserverurl_desc'] = 'The URL of the Synapse homeserver to connect to, for user and room creation.';
|
||||
$string['matrixhomeserverurl_desc'] = 'Server URL for connecting and creating accounts (e.g., https://matrix.example.com)';
|
||||
$string['matrixaccesstoken'] = 'Access token';
|
||||
$string['matrixaccesstoken_desc'] = 'Access token for the account which will perform actions on the homeserver.';
|
||||
$string['matrixelementurl'] = 'Element web URL';
|
||||
$string['matrixroomtopic'] = 'Room topic';
|
||||
$string['matrixroomtopic_help'] = 'A short description of what this room is for.';
|
||||
$string['matrixuserid'] = 'Matrix user ID';
|
||||
$string['matrix:moderator'] = 'Matrix moderator';
|
||||
$string['pluginname'] = 'Matrix';
|
||||
$string['privacy:metadata'] = 'The Matrix communication plugin does not store any personal data.';
|
||||
|
||||
@@ -30,6 +30,11 @@ if ($hassiteconfig) {
|
||||
$desc = new lang_string('matrixhomeserverurl_desc', 'communication_matrix');
|
||||
$settings->add(new admin_setting_configtext('communication_matrix/matrixhomeserverurl', $name, $desc, ''));
|
||||
|
||||
// Home server name.
|
||||
$name = new lang_string('matrixhomeservername', 'communication_matrix');
|
||||
$desc = new lang_string('matrixhomeservername_desc', 'communication_matrix');
|
||||
$settings->add(new admin_setting_configtext('communication_matrix/matrixhomeservername', $name, $desc, ''));
|
||||
|
||||
// Access token.
|
||||
$name = new lang_string('matrixaccesstoken', 'communication_matrix');
|
||||
$desc = new lang_string('matrixaccesstoken_desc', 'communication_matrix');
|
||||
|
||||
@@ -86,12 +86,13 @@ final class matrix_user_manager_test extends \advanced_testcase {
|
||||
* @param string $expecteduserid The expected matrix user id
|
||||
*/
|
||||
public function test_get_formatted_matrix_userid(
|
||||
?string $servername,
|
||||
string $server,
|
||||
string $username,
|
||||
string $expecteduserid,
|
||||
): void {
|
||||
$this->resetAfterTest();
|
||||
|
||||
set_config('matrixhomeservername', $servername, 'communication_matrix');
|
||||
set_config('matrixhomeserverurl', $server, 'communication_matrix');
|
||||
$this->assertEquals(
|
||||
$expecteduserid,
|
||||
@@ -106,27 +107,44 @@ final class matrix_user_manager_test extends \advanced_testcase {
|
||||
*/
|
||||
public static function get_formatted_matrix_userid_provider(): array {
|
||||
return [
|
||||
'servername' => [
|
||||
'example.org',
|
||||
'https://matrix.example.org',
|
||||
'user',
|
||||
'@user:example.org',
|
||||
],
|
||||
'servername empty string' => [
|
||||
'',
|
||||
'https://matrix.example.org',
|
||||
'user',
|
||||
'@user:matrix.example.org',
|
||||
],
|
||||
'alphanumeric' => [
|
||||
null,
|
||||
'https://matrix.example.org',
|
||||
'alphabet1',
|
||||
'@alphabet1:matrix.example.org',
|
||||
],
|
||||
'chara' => [
|
||||
null,
|
||||
'https://matrix.example.org',
|
||||
'asdf#$%^&*()+{}|<>?!,asdf',
|
||||
'@asdf.................asdf:matrix.example.org',
|
||||
],
|
||||
'local server' => [
|
||||
null,
|
||||
'https://synapse',
|
||||
'colin.creavey',
|
||||
'@colin.creavey:synapse',
|
||||
],
|
||||
'server with port' => [
|
||||
null,
|
||||
'https://matrix.example.org:8448',
|
||||
'colin.creavey',
|
||||
'@colin.creavey:matrix.example.org',
|
||||
],
|
||||
'numeric username' => [
|
||||
null,
|
||||
'https://matrix.example.org',
|
||||
'123456',
|
||||
'@' . matrix_user_manager::MATRIX_USER_PREFIX . '123456:matrix.example.org',
|
||||
|
||||
Reference in New Issue
Block a user