mirror of
https://github.com/dartdavros/chatballs.git
synced 2026-10-14 13:19:01 +03:00
19 lines
937 B
Python
19 lines
937 B
Python
from django.db import models
|
|
|
|
from hub_platform.tenancy.models import TenantRelationModel
|
|
|
|
# Анонимная браузерная сессия Web Chat (SPEC-HUB-0003 §7). Храним только hash
|
|
# токена; токен живёт в браузере и идентифицирует ConnectionIdentity канала.
|
|
|
|
|
|
class WebSession(TenantRelationModel):
|
|
tenant_relation_fields = ("connection", "identity")
|
|
token_hash = models.CharField(max_length=64, unique=True, db_index=True)
|
|
connection = models.ForeignKey("integrations.Integration", on_delete=models.CASCADE, related_name="web_sessions")
|
|
identity = models.ForeignKey("conversations.ConnectionIdentity", on_delete=models.CASCADE, related_name="web_sessions")
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
last_seen_at = models.DateTimeField(auto_now=True)
|
|
|
|
def __str__(self) -> str:
|
|
return f"websession:{self.identity_id}"
|