fix 500 error

pull/226/head
Aevann 2024-04-16 23:31:07 +02:00
parent e7a7784047
commit 28da199b5b
1 changed files with 14 additions and 13 deletions

View File

@ -285,20 +285,21 @@ def remove_orgy(v, created_utc, chat_id):
elif v.id != chat.owner_id: elif v.id != chat.owner_id:
abort(403, "Only the chat owner can manage its orgies!") abort(403, "Only the chat owner can manage its orgies!")
orgy = g.db.query(Orgy).filter_by(created_utc=created_utc).one() orgy = g.db.query(Orgy).filter_by(created_utc=created_utc).one_or_none()
if chat.id == 1: if orgy:
ma = ModAction( if chat.id == 1:
kind="remove_orgy", ma = ModAction(
user_id=v.id, kind="remove_orgy",
_note=f'<a href="{orgy.data}" rel="nofollow noopener">{orgy.title}</a>', user_id=v.id,
) _note=f'<a href="{orgy.data}" rel="nofollow noopener">{orgy.title}</a>',
g.db.add(ma) )
g.db.add(ma)
started = orgy.started started = orgy.started
g.db.delete(orgy) g.db.delete(orgy)
g.db.commit() g.db.commit()
if started: if started:
requests.post(f'http://localhost:5001/chat/{chat_id}/refresh_chat', headers={"User-Agent": "refreshing_chat", "Host": SITE}) requests.post(f'http://localhost:5001/chat/{chat_id}/refresh_chat', headers={"User-Agent": "refreshing_chat", "Host": SITE})
return {"message": "Orgy stopped successfully!"} return {"message": "Orgy stopped successfully!"}