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
28245366
Commit
28245366
authored
3 years ago
by
Thomas Hackl
Browse files
Options
Downloads
Patches
Plain Diff
permission handling finally working as planned
parent
8404cc8b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
models/MatrixRoom.php
+27
-18
27 additions, 18 deletions
models/MatrixRoom.php
plugin.manifest
+1
-1
1 addition, 1 deletion
plugin.manifest
vendor/libpatrix
+1
-1
1 addition, 1 deletion
vendor/libpatrix
with
29 additions
and
20 deletions
models/MatrixRoom.php
+
27
−
18
View file @
28245366
...
...
@@ -25,21 +25,23 @@ class MatrixRoom extends SimpleORMap
const
POWER_LEVEL_AUTOR
=
0
;
const
POWER_LEVEL_TUTOR
=
50
;
const
POWER_LEVEL_DOZENT
=
50
;
const
EVENT
_POWER_LEVELS
=
[
const
ROOM
_POWER_LEVELS
=
[
'events'
=>
[
'ban'
=>
self
::
POWER_LEVEL_TUTOR
,
'invite'
=>
self
::
POWER_LEVEL_TUTOR
,
'kick'
=>
self
::
POWER_LEVEL_TUTOR
,
'm.room.name'
=>
self
::
POWER_LEVEL_DOZENT
,
'm.room.power_levels'
=>
self
::
POWER_LEVEL_DOZENT
,
'notifications'
=>
[
'room'
=>
self
::
POWER_LEVEL_TUTOR
],
'redact'
=>
self
::
POWER_LEVEL_TUTOR
],
'events_default'
=>
self
::
POWER_LEVEL_AUTOR
,
'state_default'
=>
self
::
POWER_LEVEL_TUTOR
,
'users_default'
=>
self
::
POWER_LEVEL_AUTOR
'notifications'
=>
[
'room'
=>
self
::
POWER_LEVEL_TUTOR
],
'defaults'
=>
[
'events_default'
=>
self
::
POWER_LEVEL_AUTOR
,
'state_default'
=>
self
::
POWER_LEVEL_TUTOR
,
'users_default'
=>
self
::
POWER_LEVEL_AUTOR
]
];
protected
static
function
configure
(
$config
=
[])
...
...
@@ -67,7 +69,7 @@ class MatrixRoom extends SimpleORMap
// Invite all members with existing Matrix account to newly created room.
$invites
=
[];
// Permission levels in the room to create.
/*
$permissions = [
$permissions
=
[
$sysaccount
->
getUserId
()
=>
100
];
$accounts
=
[];
...
...
@@ -88,18 +90,21 @@ class MatrixRoom extends SimpleORMap
$power_level
=
MatrixRoom
::
POWER_LEVEL_AUTOR
;
}
// Collect accounts for auto-joining room.
$accounts[$mapped->matrix_account_id] = $mapped->getLinkedAccount();
// Collect permissions for setting power levels.
$permissions
[
$mapped
->
matrix_account_id
]
=
$power_level
;
}
}
$power_levels = self::EVENT_POWER_LEVELS;
$power_levels['users'] = $permissions;*/
$permission_set
=
new
Patrix\RoomPermissionSet
(
self
::
ROOM_POWER_LEVELS
[
'defaults'
],
$permissions
,
self
::
ROOM_POWER_LEVELS
[
'events'
],
self
::
ROOM_POWER_LEVELS
[
'notifications'
],
self
::
POWER_LEVEL_AUTOR
);
$newRoom
=
MatrixClient
::
get
()
->
createRoom
(
$sysaccount
,
Context
::
getHeaderLine
(),
false
,
''
,
[],
self
::
EVENT_POWER_LEVELS
);
[],
$permission_set
);
$mapping
=
new
self
();
$mapping
->
range_id
=
$context
->
getId
();
...
...
@@ -141,12 +146,16 @@ class MatrixRoom extends SimpleORMap
$perm
=
self
::
POWER_LEVEL_AUTOR
;
}
}
$permission
=
[
$account
->
getUserName
()
=>
$perm
]
;
// Get existing room permissions so that they are not completely overwritten when adding the current user.
$permission
s
=
MatrixClient
::
get
()
->
getRoomPermissionLevels
(
$sysaccount
,
$this
->
getLinkedRoom
())
->
getUserPermissions
()
;
//MatrixClient::get()->setRoomUserPermissionLevels($sysaccount, $this->getLinkedRoom(), $permission);
$permissions
[
$account
->
getUserName
()]
=
$perm
;
// Set correct permission for current user.
MatrixClient
::
get
()
->
setRoomUserPermissionLevels
(
$sysaccount
,
$this
->
getLinkedRoom
(),
$permissions
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plugin.manifest
+
1
−
1
View file @
28245366
pluginname=Matrix-Chat
pluginclassname=MatrixPlugin
origin=data-quest
version=0.
85
version=0.
9
screenshot=assets/images/matrix_logo.png
description=Matrix chat for Stud.IP courses
studipMinVersion=4.5
...
...
This diff is collapsed.
Click to expand it.
libpatrix
@
c05790e0
Subproject commit
a63da521cef79651fbdc95b90298b5b67882957
d
Subproject commit
c05790e055ca90fe7d5867ee6dbd26fd695814a
d
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