Commit ffe3f5f3 authored by Lars Kruse's avatar Lars Kruse
Browse files

feat(matrix_chat): invite new members to group rooms

parent acc71476
......@@ -6,9 +6,10 @@ from django.dispatch import receiver
from huey.contrib.djhuey import db_task
from grouprise.core.templatetags.defaultfilters import full_url
import grouprise.features.groups.models
import grouprise.features.contributions.models
import grouprise.features.content.models
import grouprise.features.contributions.models
import grouprise.features.groups.models
import grouprise.features.memberships.models
from .matrix_bot import MatrixBot, MatrixError
from .models import MatrixChatGroupRoom
......@@ -112,3 +113,24 @@ def send_contribution_notification_to_matrix_rooms(sender, instance, created, **
summary = f"Diskussionsbeitrag: [{instance.container.subject} ({author})]({url})"
messages.append((group, summary, instance.public))
@receiver(post_save, sender=grouprise.features.memberships.models.Membership)
def synchronize_matrix_room_memberships(sender, instance, created, **kwargs):
if created:
def _invite_to_group_rooms(group):
async def _invite_to_group_rooms_delayed(group):
async with MatrixBot() as bot:
async for invited in bot.send_invitations_to_group_members(group):"Invitation sent: {invited}")
except MatrixError as exc:
f"Failed to invite new group members ({group}) to matrix rooms: {exc}"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment