From ad75fbc8743451495cc900a282fb0465a6d06d07 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 22 Jan 2022 01:04:10 +0200 Subject: [PATCH] fdsfds --- files/routes/front.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/files/routes/front.py b/files/routes/front.py index a7b3aa8784..67917e87b6 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -14,6 +14,24 @@ def clear(v): g.db.commit() return {"message": "Notifications cleared!"} +@app.get("/unread") +@auth_required +def unread(v): + listing = g.db.query(Comment).join(Notification.comment).filter( + Notification.read == False, + Notification.user_id == v.id, + Comment.is_banned == False, + Comment.deleted_utc == 0, + Comment.author_id != AUTOJANNY_ID, + ).order_by(Notification.id.desc()).all() + + for n in v.notifications.filter_by(read=False).all(): + n.read = True + g.db.add(n) + g.db.commit() + + return {"data":[x.json for x in listing]} + @app.get("/notifications") @auth_required def notifications(v):