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
a6bb2229
Verified
Commit
a6bb2229
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Move all matrix util imports to top level
parent
d8194ef6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Resolve "Review tasks"
Pipeline
#55931
failed
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
+2
-15
2 additions, 15 deletions
aleksis/apps/matrix/models.py
with
2 additions
and
15 deletions
aleksis/apps/matrix/models.py
+
2
−
15
View file @
a6bb2229
...
...
@@ -10,7 +10,7 @@ from aleksis.core.mixins import ExtensibleModel, ExtensiblePolymorphicModel
from
aleksis.core.models
import
Group
,
Person
from
aleksis.core.util.core_helpers
import
get_site_preferences
from
.util.matrix
import
do_matrix_request
from
.util.matrix
import
MatrixException
,
do_matrix_request
class
MatrixProfile
(
ExtensibleModel
):
...
...
@@ -74,8 +74,6 @@ class MatrixRoom(ExtensiblePolymorphicModel):
@classmethod
def
from_group
(
cls
,
group
:
Group
)
->
"
MatrixRoom
"
:
"""
Create a Matrix room from a group.
"""
from
.util.matrix
import
MatrixException
,
do_matrix_request
try
:
room
=
cls
.
get_queryset
().
get
(
group
=
group
)
except
cls
.
DoesNotExist
:
...
...
@@ -97,12 +95,11 @@ class MatrixRoom(ExtensiblePolymorphicModel):
r
=
cls
.
_create_room
(
group
.
name
,
alias
,
profiles_to_invite
)
alias_found
=
True
except
MatrixException
as
e
:
print
(
e
.
args
,
get_site_preferences
()[
"
matrix__disambiguate_room_aliases
"
])
if
(
not
get_site_preferences
()[
"
matrix__disambiguate_room_aliases
"
]
or
e
.
args
[
0
].
get
(
"
errcode
"
)
!=
"
M_ROOM_IN_USE
"
):
raise
MatrixException
(
*
e
.
args
)
raise
match
=
re
.
match
(
r
"
^(.*)-(\d+)$
"
,
alias
)
if
match
:
...
...
@@ -127,8 +124,6 @@ class MatrixRoom(ExtensiblePolymorphicModel):
invite
:
Optional
[
list
[
str
]]
=
None
,
creation_content
:
Optional
[
dict
]
=
None
,
)
->
dict
[
str
,
Any
]:
from
.util.matrix
import
do_matrix_request
body
=
{
"
preset
"
:
"
private_chat
"
,
"
name
"
:
name
,
"
room_alias_name
"
:
alias
}
if
invite
:
...
...
@@ -144,8 +139,6 @@ class MatrixRoom(ExtensiblePolymorphicModel):
@property
def
power_levels
(
self
)
->
dict
[
str
,
int
]:
"""
Return the power levels for this room.
"""
from
.util.matrix
import
do_matrix_request
r
=
do_matrix_request
(
"
GET
"
,
f
"
rooms/
{
self
.
room_id
}
/state
"
)
event
=
list
(
filter
(
lambda
x
:
x
[
"
type
"
]
==
"
m.room.power_levels
"
,
r
))
...
...
@@ -155,8 +148,6 @@ class MatrixRoom(ExtensiblePolymorphicModel):
@property
def
members
(
self
)
->
list
[
str
]:
from
.util.matrix
import
do_matrix_request
r
=
do_matrix_request
(
"
GET
"
,
f
"
rooms/
{
self
.
room_id
}
/members
"
,
body
=
{
"
membership
"
:
[
"
join
"
,
"
invite
"
]}
)
...
...
@@ -164,8 +155,6 @@ class MatrixRoom(ExtensiblePolymorphicModel):
def
_invite
(
self
,
profile
:
MatrixProfile
)
->
dict
[
str
,
Any
]:
"""
Invite a user to this room.
"""
from
.util.matrix
import
do_matrix_request
r
=
do_matrix_request
(
"
POST
"
,
f
"
rooms/
{
self
.
room_id
}
/invite
"
,
...
...
@@ -281,8 +270,6 @@ class MatrixSpace(MatrixRoom):
@property
def
child_spaces
(
self
)
->
list
[
str
]:
"""
Get all child spaces of this space.
"""
from
.util.matrix
import
do_matrix_request
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
"
]
...
...
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