fix 500 errors
parent
b2098a78bf
commit
6ea5761ea2
|
@ -6,6 +6,7 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
|
from files.helpers.config.const import *
|
||||||
|
|
||||||
class Chat(Base):
|
class Chat(Base):
|
||||||
__tablename__ = "chats"
|
__tablename__ = "chats"
|
||||||
|
@ -18,6 +19,8 @@ class Chat(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def owner_id(self):
|
def owner_id(self):
|
||||||
|
if not self.memberships:
|
||||||
|
return AUTOJANNY_ID
|
||||||
return self.memberships[0].user_id
|
return self.memberships[0].user_id
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
|
@ -35,7 +35,7 @@ def chat_user(v, username):
|
||||||
if existing:
|
if existing:
|
||||||
return redirect(f"/chat/{existing.id}")
|
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.add(chat)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue