Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Matrix
Commits
81bdaa12
Verified
Commit
81bdaa12
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Drop semantically wrong properties and use getters
parent
2f4bea19
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Resolve "Review tasks"
Pipeline
#56070
canceled
3 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Stage: docker
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/matrix/models.py
+7
-10
7 additions, 10 deletions
aleksis/apps/matrix/models.py
with
7 additions
and
10 deletions
aleksis/apps/matrix/models.py
+
7
−
10
View file @
81bdaa12
...
...
@@ -136,8 +136,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return
r
@property
def
power_levels
(
self
)
->
dict
[
str
,
int
]:
def
get_power_levels
(
self
)
->
dict
[
str
,
int
]:
"""
Return the power levels for this room.
"""
r
=
do_matrix_request
(
"
GET
"
,
f
"
rooms/
{
self
.
room_id
}
/state
"
)
...
...
@@ -146,8 +145,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return
user_levels
@property
def
members
(
self
)
->
list
[
str
]:
def
get_members
(
self
)
->
list
[
str
]:
r
=
do_matrix_request
(
"
GET
"
,
f
"
rooms/
{
self
.
room_id
}
/members
"
,
body
=
{
"
membership
"
:
[
"
join
"
,
"
invite
"
]}
)
...
...
@@ -202,7 +200,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
def
sync_profiles
(
self
):
"""
Sync profiles for this room.
"""
all_profiles
=
self
.
get_profiles
()
members
=
self
.
members
members
=
self
.
get_
members
()
# Invite all users who are not in the room yet
for
profile
in
all_profiles
:
...
...
@@ -211,7 +209,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
self
.
_invite
(
profile
)
# Set power levels for all users
user_levels
=
self
.
power_levels
user_levels
=
self
.
get_
power_levels
()
for
profile
in
all_profiles
:
if
profile
.
person
in
self
.
group
.
owners
.
all
():
power_level
=
get_site_preferences
()[
"
matrix__power_level_for_owners
"
]
...
...
@@ -272,9 +270,8 @@ class MatrixSpace(MatrixRoom):
creation_content
[
"
type
"
]
=
"
m.space
"
return
super
().
_create_room
(
name
,
alias
,
invite
,
creation_content
)
@property
def
child_spaces
(
self
)
->
list
[
str
]:
"""
Get all child spaces of this space.
"""
def
get_children
(
self
)
->
list
[
str
]:
"""
Get all children (rooms/spaces) of this space.
"""
r
=
do_matrix_request
(
"
GET
"
,
f
"
rooms/
{
self
.
room_id
}
/state
"
)
return
[
c
[
"
state_key
"
]
for
c
in
r
if
c
[
"
type
"
]
==
"
m.space.child
"
]
...
...
@@ -289,7 +286,7 @@ class MatrixSpace(MatrixRoom):
def
sync_children
(
self
):
"""
Sync membership of child spaces and rooms.
"""
current_children
=
self
.
child
_spaces
current_children
=
self
.
get_
child
ren
()
child_spaces
=
MatrixSpace
.
get_queryset
().
filter
(
group__in
=
self
.
group
.
child_groups
.
filter
(
child_groups__isnull
=
False
)
)
...
...
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