Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MatrixPlugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stud.IP
Plugins
MatrixPlugin
Commits
48bed5ce
Commit
48bed5ce
authored
1 year ago
by
Thomas Hackl
Browse files
Options
Downloads
Patches
Plain Diff
catch exception if user has already left the matrix room so that they can't be removed anymore
parent
80a5fa93
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MatrixPlugin.php
+27
-24
27 additions, 24 deletions
MatrixPlugin.php
plugin.manifest
+1
-1
1 addition, 1 deletion
plugin.manifest
with
28 additions
and
25 deletions
MatrixPlugin.php
+
27
−
24
View file @
48bed5ce
...
@@ -157,30 +157,33 @@ class MatrixPlugin extends StudIPPlugin implements StandardPlugin
...
@@ -157,30 +157,33 @@ class MatrixPlugin extends StudIPPlugin implements StandardPlugin
$matrix
=
MatrixAccount
::
findOneByUser_id
(
$membership
->
user_id
);
$matrix
=
MatrixAccount
::
findOneByUser_id
(
$membership
->
user_id
);
$room
=
MatrixRoom
::
findOneByRange_id
(
$membership
->
seminar_id
);
$room
=
MatrixRoom
::
findOneByRange_id
(
$membership
->
seminar_id
);
if
(
is_a
(
$matrix
,
MatrixAccount
::
class
)
&&
is_a
(
$room
,
MatrixRoom
::
class
))
{
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.
try
{
* Otherwise we use the Stud.IP system account to kick the user from the room.
/*
*/
* leaveRoom can only be used if we don't authorize our Matrix users with SSO and login token stuff.
if
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN
)
{
* Otherwise we use the Stud.IP system account to kick the user from the room.
// POST body.
*/
$data
=
[
if
(
Config
::
get
()
->
MATRIX_SYSTEM_ACCOUNT_ACCESS_TOKEN
)
{
'user_id'
=>
$matrix
->
matrix_account_id
,
// POST body.
'reason'
=>
sprintf
(
'Not a member of course "%s" anymore.'
,
$membership
->
course
->
getFullname
())
$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'
,
MatrixClient
::
get
()
->
requestServer
(
$data
,
sprintf
(
'/_matrix/client/r0/rooms/%s/kick'
,
$room
->
matrix_room_id
),
[],
'POST'
,
MatrixAccount
::
requireSystemAccount
()
$data
,
);
[],
}
else
{
MatrixAccount
::
requireSystemAccount
()
MatrixClient
::
get
()
->
leaveRoom
(
);
$matrix
->
getLinkedAccount
(),
}
else
{
$room
->
getLinkedRoom
()
MatrixClient
::
get
()
->
leaveRoom
(
);
$matrix
->
getLinkedAccount
(),
}
$room
->
getLinkedRoom
()
);
}
}
catch
(
Exception
$e
)
{}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
plugin.manifest
+
1
−
1
View file @
48bed5ce
pluginname=Matrix-Chat
pluginname=Matrix-Chat
pluginclassname=MatrixPlugin
pluginclassname=MatrixPlugin
origin=data-quest
origin=data-quest
version=1.4.
6
version=1.4.
7
screenshot=assets/images/matrix_logo.png
screenshot=assets/images/matrix_logo.png
description=Matrix chat for Stud.IP courses
description=Matrix chat for Stud.IP courses
studipMinVersion=4.5
studipMinVersion=4.5
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment