From 9a550aa5a051d91350bba01d0c94f9a83313cce5 Mon Sep 17 00:00:00 2001 From: Thomas Hackl <hackl@data-quest.de> Date: Mon, 8 Nov 2021 14:56:48 +0100 Subject: [PATCH] use manual path --- controllers/matrix_chat.php | 7 +++++++ migrations/20210519_init_matrix_chat.php | 8 ++++++++ models/MatrixClient.php | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/controllers/matrix_chat.php b/controllers/matrix_chat.php index 112ff01..dbbb664 100644 --- a/controllers/matrix_chat.php +++ b/controllers/matrix_chat.php @@ -42,6 +42,13 @@ class MatrixChatController extends AuthenticatedController // Check if current user has a Matrix account. $this->account = MatrixAccount::find(User::findCurrent()->id); + + // If no account is found, try to search in Matrix user directory. + $found = MatrixClient::get()->searchUsers( + MatrixAccount::requireSystemAccount(), '@studip_test1:', 1); + + PageLayout::postInfo('<pre>' . print_r($found, 1) . '</pre>'); + $this->no_account_wanted = UserConfig::get(User::findCurrent()->id)->MATRIX_NO_ACCOUNT_WANTED; if ($this->account) { diff --git a/migrations/20210519_init_matrix_chat.php b/migrations/20210519_init_matrix_chat.php index 4ad10fd..47381a3 100644 --- a/migrations/20210519_init_matrix_chat.php +++ b/migrations/20210519_init_matrix_chat.php @@ -76,6 +76,14 @@ class InitMatrixChat extends Migration 'range' => 'global', 'section' => 'matrix', 'description' => 'URL des Chatservers (z.B. Element)' + ], + 'AUTO_CREATE_ACCOUNTS' => [ + 'value' => false, + 'type' => 'bool', + 'range' => 'global', + 'section' => 'matrix', + 'description' => 'Soll automatisch versucht werden, Matrixaccounts anzulegen? Andernfalls wird ' . + 'ein Link zum Chatserver angezeigt.' ] ]; diff --git a/models/MatrixClient.php b/models/MatrixClient.php index ceddde4..881d865 100644 --- a/models/MatrixClient.php +++ b/models/MatrixClient.php @@ -29,7 +29,10 @@ class MatrixClient public static function get() { if (is_null(MatrixClient::$client)) { - MatrixClient::$client = new Patrix\MatrixClient(Config::get()->MATRIX_SERVER_HOSTNAME); + MatrixClient::$client = new Patrix\MatrixClient( + Config::get()->MATRIX_SERVER_HOSTNAME, + 'https://' . Config::get()->MATRIX_SERVER_HOSTNAME + ); } return MatrixClient::$client; -- GitLab