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
d8194ef6
Verified
Commit
d8194ef6
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fix typing
parent
b9b30782
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Resolve "Review tasks"
Pipeline
#55929
canceled
3 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Stage: docker
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/matrix/models.py
+10
-10
10 additions, 10 deletions
aleksis/apps/matrix/models.py
aleksis/apps/matrix/util/matrix.py
+2
-2
2 additions, 2 deletions
aleksis/apps/matrix/util/matrix.py
with
12 additions
and
12 deletions
aleksis/apps/matrix/models.py
+
10
−
10
View file @
d8194ef6
import
re
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Union
from
typing
import
Any
,
Optional
,
Union
from
django.db
import
models
from
django.db.models
import
Q
...
...
@@ -124,9 +124,9 @@ class MatrixRoom(ExtensiblePolymorphicModel):
self
,
name
,
alias
,
invite
:
Optional
[
L
ist
[
str
]]
=
None
,
invite
:
Optional
[
l
ist
[
str
]]
=
None
,
creation_content
:
Optional
[
dict
]
=
None
,
)
->
D
ict
[
str
,
Any
]:
)
->
d
ict
[
str
,
Any
]:
from
.util.matrix
import
do_matrix_request
body
=
{
"
preset
"
:
"
private_chat
"
,
"
name
"
:
name
,
"
room_alias_name
"
:
alias
}
...
...
@@ -142,7 +142,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return
r
@property
def
power_levels
(
self
)
->
D
ict
[
str
,
int
]:
def
power_levels
(
self
)
->
d
ict
[
str
,
int
]:
"""
Return the power levels for this room.
"""
from
.util.matrix
import
do_matrix_request
...
...
@@ -154,7 +154,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return
user_levels
@property
def
members
(
self
)
->
L
ist
[
str
]:
def
members
(
self
)
->
l
ist
[
str
]:
from
.util.matrix
import
do_matrix_request
r
=
do_matrix_request
(
...
...
@@ -162,7 +162,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
)
return
[
m
[
"
state_key
"
]
for
m
in
r
[
"
chunk
"
]]
def
_invite
(
self
,
profile
:
MatrixProfile
)
->
D
ict
[
str
,
Any
]:
def
_invite
(
self
,
profile
:
MatrixProfile
)
->
d
ict
[
str
,
Any
]:
"""
Invite a user to this room.
"""
from
.util.matrix
import
do_matrix_request
...
...
@@ -173,7 +173,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
)
return
r
def
_set_power_levels
(
self
,
power_levels
:
D
ict
[
str
,
int
])
->
D
ict
[
str
,
Any
]:
def
_set_power_levels
(
self
,
power_levels
:
d
ict
[
str
,
int
])
->
d
ict
[
str
,
Any
]:
"""
Set the power levels for this room.
"""
r
=
do_matrix_request
(
"
PUT
"
,
...
...
@@ -270,16 +270,16 @@ class MatrixSpace(MatrixRoom):
self
,
name
,
alias
,
invite
:
Optional
[
L
ist
[
str
]]
=
None
,
invite
:
Optional
[
l
ist
[
str
]]
=
None
,
creation_content
:
Optional
[
dict
]
=
None
,
)
->
D
ict
[
str
,
Any
]:
)
->
d
ict
[
str
,
Any
]:
if
not
creation_content
:
creation_content
=
{}
creation_content
[
"
type
"
]
=
"
m.space
"
return
super
().
_create_room
(
name
,
alias
,
invite
,
creation_content
)
@property
def
child_spaces
(
self
)
->
L
ist
[
str
]:
def
child_spaces
(
self
)
->
l
ist
[
str
]:
"""
Get all child spaces of this space.
"""
from
.util.matrix
import
do_matrix_request
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/matrix/util/matrix.py
+
2
−
2
View file @
d8194ef6
import
time
from
json
import
JSONDecodeError
from
typing
import
Any
,
Dict
,
Optional
from
typing
import
Any
,
Optional
from
urllib.parse
import
urljoin
import
requests
...
...
@@ -24,7 +24,7 @@ def get_headers():
}
def
do_matrix_request
(
method
:
str
,
url
:
str
,
body
:
Optional
[
dict
]
=
None
)
->
D
ict
[
str
,
Any
]:
def
do_matrix_request
(
method
:
str
,
url
:
str
,
body
:
Optional
[
dict
]
=
None
)
->
d
ict
[
str
,
Any
]:
"""
Do a HTTP request to the Matrix Client Server API.
"""
while
True
:
res
=
requests
.
request
(
method
=
method
,
url
=
build_url
(
url
),
headers
=
get_headers
(),
json
=
body
)
...
...
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