Allow linking chats

This commit is contained in:
2026-02-19 17:13:34 +00:00
parent bac2841298
commit 0816687c71
15 changed files with 369 additions and 461 deletions

View File

@@ -173,7 +173,7 @@ class PersonIdentifier(models.Model):
class PlatformChatLink(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
person = models.ForeignKey(Person, on_delete=models.CASCADE)
person = models.ForeignKey(Person, on_delete=models.CASCADE, null=True, blank=True)
person_identifier = models.ForeignKey(
PersonIdentifier,
on_delete=models.SET_NULL,
@@ -184,6 +184,7 @@ class PlatformChatLink(models.Model):
chat_identifier = models.CharField(max_length=255)
chat_jid = models.CharField(max_length=255, blank=True, null=True)
chat_name = models.CharField(max_length=255, blank=True, null=True)
is_group = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
@@ -224,7 +225,7 @@ class PlatformChatLink(models.Model):
return super().save(*args, **kwargs)
def __str__(self):
return f"{self.person.name} ({self.service}: {self.chat_identifier})"
return f"{self.person.name if self.person_id else self.chat_name or self.chat_identifier} ({self.service}: {self.chat_identifier})"
class ChatSession(models.Model):