Implement XMPP relaying
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user