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
6e6218e6
Verified
Commit
6e6218e6
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add tasks for syncing rooms periodically or after changes
parent
5c6d77f5
No related branches found
No related tags found
1 merge request
!7
Resolve "Add periodic task for syncing rooms"
Pipeline
#64061
failed
3 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Stage: docker
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/apps/matrix/apps.py
+9
-0
9 additions, 0 deletions
aleksis/apps/matrix/apps.py
aleksis/apps/matrix/signals.py
+12
-0
12 additions, 0 deletions
aleksis/apps/matrix/signals.py
aleksis/apps/matrix/tasks.py
+9
-0
9 additions, 0 deletions
aleksis/apps/matrix/tasks.py
with
30 additions
and
0 deletions
aleksis/apps/matrix/apps.py
+
9
−
0
View file @
6e6218e6
from
django.db.models.signals
import
post_save
from
aleksis.core.util.apps
import
AppConfig
...
...
@@ -11,3 +13,10 @@ class DefaultConfig(AppConfig):
}
licence
=
"
EUPL-1.2+
"
copyright_info
=
(([
2021
,
2022
],
"
Jonathan Weth
"
,
"
dev@jonathanweth.de
"
),)
def
ready
(
self
):
from
aleksis.core.models
import
Group
from
.signals
import
post_save_matrix_signal
post_save
.
connect
(
post_save_matrix_signal
,
sender
=
Group
)
This diff is collapsed.
Click to expand it.
aleksis/apps/matrix/signals.py
0 → 100644
+
12
−
0
View file @
6e6218e6
from
aleksis.apps.matrix.models
import
MatrixRoom
from
.tasks
import
sync_room
def
post_save_matrix_signal
(
sender
,
instance
,
created
,
**
kwargs
):
"""
Sync Matrix room after changing a group.
"""
if
created
:
return
for
room
in
MatrixRoom
.
objects
.
filter
(
group
=
instance
):
sync_room
.
delay
(
room
.
pk
)
This diff is collapsed.
Click to expand it.
aleksis/apps/matrix/tasks.py
+
9
−
0
View file @
6e6218e6
from
datetime
import
timedelta
from
typing
import
Sequence
from
aleksis.apps.matrix.models
import
MatrixRoom
...
...
@@ -25,3 +26,11 @@ def provision_group_in_matrix(pk: int):
"""
Provision provided group in Matrix.
"""
group
=
Group
.
objects
.
get
(
pk
=
pk
)
group
.
_provision_in_matrix
()
@app.task
(
run_every
=
timedelta
(
days
=
1
))
def
sync_rooms
():
"""
Synchronise all Matrix rooms.
"""
rooms
=
MatrixRoom
.
objects
.
all
()
for
room
in
rooms
:
room
.
sync
()
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