diff --git a/MatrixPlugin.php b/MatrixPlugin.php index c1618ca1e49f0fa7d0643ca4e319b320c7107be5..938395c74a8bce8e46c50362d45d1e2fc3f93086 100644 --- a/MatrixPlugin.php +++ b/MatrixPlugin.php @@ -157,30 +157,33 @@ class MatrixPlugin extends StudIPPlugin implements StandardPlugin $matrix = MatrixAccount::findOneByUser_id($membership->user_id); $room = MatrixRoom::findOneByRange_id($membership->seminar_id); if (is_a($matrix, MatrixAccount::class) && is_a($room, MatrixRoom::class)) { - /* - * leaveRoom can only be used if we don't authorize our Matrix users with SSO and login token stuff. - * Otherwise we use the Stud.IP system account to kick the user from the room. - */ - if (Config::get()->MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN) { - // POST body. - $data = [ - 'user_id' => $matrix->matrix_account_id, - 'reason' => sprintf('Not a member of course "%s" anymore.', $membership->course->getFullname()) - ]; - - MatrixClient::get()->requestServer( - sprintf('/_matrix/client/r0/rooms/%s/kick', $room->matrix_room_id), - 'POST', - $data, - [], - MatrixAccount::requireSystemAccount() - ); - } else { - MatrixClient::get()->leaveRoom( - $matrix->getLinkedAccount(), - $room->getLinkedRoom() - ); - } + + try { + /* + * leaveRoom can only be used if we don't authorize our Matrix users with SSO and login token stuff. + * Otherwise we use the Stud.IP system account to kick the user from the room. + */ + if (Config::get()->MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN) { + // POST body. + $data = [ + 'user_id' => $matrix->matrix_account_id, + 'reason' => sprintf('Not a member of course "%s" anymore.', $membership->course->getFullname()) + ]; + + MatrixClient::get()->requestServer( + sprintf('/_matrix/client/r0/rooms/%s/kick', $room->matrix_room_id), + 'POST', + $data, + [], + MatrixAccount::requireSystemAccount() + ); + } else { + MatrixClient::get()->leaveRoom( + $matrix->getLinkedAccount(), + $room->getLinkedRoom() + ); + } + } catch (Exception $e) {} } } diff --git a/plugin.manifest b/plugin.manifest index 1e7a6c22d9b15d19c17fcc810ba7bf513a4a683d..c104c45e440d3cf6ef21d1d3f1111d98b40ff971 100644 --- a/plugin.manifest +++ b/plugin.manifest @@ -1,7 +1,7 @@ pluginname=Matrix-Chat pluginclassname=MatrixPlugin origin=data-quest -version=1.4.6 +version=1.4.7 screenshot=assets/images/matrix_logo.png description=Matrix chat for Stud.IP courses studipMinVersion=4.5