Implement XMPP relaying

This commit is contained in:
2025-02-21 21:34:47 +00:00
parent abcb038051
commit 4c4d6529d0
17 changed files with 941 additions and 77 deletions

View File

@@ -5,6 +5,7 @@ from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.db import models
from core.lib.notify import raw_sendmsg
from core.clients import signalapi
logger = logging.getLogger(__name__)
@@ -118,6 +119,20 @@ class PersonIdentifier(models.Model):
def __str__(self):
return f"{self.person} ({self.service})"
def send(self, text):
"""
Send this contact a text.
"""
if self.service == "signal":
ts = signalapi.send_message_raw_sync(
self.identifier,
text
)
return ts
else:
raise NotImplementedError(f"Service not implemented: {self.service}")
class ChatSession(models.Model):
"""Represents an ongoing chat session, stores summarized history."""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
@@ -244,6 +259,9 @@ class Manipulation(models.Model):
blank=True, null=True
)
def __str__(self):
return f"{self.name} [{self.group}]"
# class Perms(models.Model):
# class Meta: