From 6ea5761ea28d4c279a3f52bfcd7e1b27943e2ac1 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 7 Apr 2024 10:46:34 +0200 Subject: [PATCH] fix 500 errors --- files/classes/chats.py | 3 +++ files/routes/chats.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/files/classes/chats.py b/files/classes/chats.py index 50672b8f6..8852e893a 100644 --- a/files/classes/chats.py +++ b/files/classes/chats.py @@ -6,6 +6,7 @@ from sqlalchemy.sql.sqltypes import * from files.classes import Base from files.helpers.lazy import lazy +from files.helpers.config.const import * class Chat(Base): __tablename__ = "chats" @@ -18,6 +19,8 @@ class Chat(Base): @property @lazy def owner_id(self): + if not self.memberships: + return AUTOJANNY_ID return self.memberships[0].user_id def __init__(self, *args, **kwargs): diff --git a/files/routes/chats.py b/files/routes/chats.py index 4e2ecfe77..49f44897d 100644 --- a/files/routes/chats.py +++ b/files/routes/chats.py @@ -35,7 +35,7 @@ def chat_user(v, username): if existing: return redirect(f"/chat/{existing.id}") - chat = Chat(owner_id=v.id, name=f"@{v.username}, @{user.username}") + chat = Chat(name=f"@{v.username}, @{user.username}") g.db.add(chat) g.db.flush()