move modmail notifs after messages

pull/222/head
Aevann 2024-02-01 18:00:51 +02:00
parent 03f7322725
commit 40c6c647c6
1 changed files with 37 additions and 38 deletions

View File

@ -56,44 +56,6 @@ def unread(v):
return {"data":[x[1].json for x in listing]}
@app.get("/notifications/modmail")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@admin_level_required(PERMS['VIEW_MODMAIL'])
def notifications_modmail(v):
page = get_page()
comments = g.db.query(Comment).filter_by(
sentto=MODMAIL_ID,
level=1,
)
total = comments.count()
listing = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all()
for c in listing:
c_and_children = [c] + c.replies('old')
for c in c_and_children:
if c.author_id == v.id: continue
c.unread = c.created_utc > v.last_viewed_modmail_notifs
if not session.get("GLOBAL") and not request.values.get('nr'):
v.last_viewed_modmail_notifs = int(time.time())
g.db.add(v)
if v.client: return {"data":[x.json for x in listing]}
return render_template("notifications.html",
v=v,
notifications=listing,
total=total,
page=page,
standalone=True,
render_replies=True,
)
@app.get("/notifications/messages")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@ -169,6 +131,43 @@ def notifications_messages(v):
)
@app.get("/notifications/modmail")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@admin_level_required(PERMS['VIEW_MODMAIL'])
def notifications_modmail(v):
page = get_page()
comments = g.db.query(Comment).filter_by(
sentto=MODMAIL_ID,
level=1,
)
total = comments.count()
listing = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all()
for c in listing:
c_and_children = [c] + c.replies('old')
for c in c_and_children:
if c.author_id == v.id: continue
c.unread = c.created_utc > v.last_viewed_modmail_notifs
if not session.get("GLOBAL") and not request.values.get('nr'):
v.last_viewed_modmail_notifs = int(time.time())
g.db.add(v)
if v.client: return {"data":[x.json for x in listing]}
return render_template("notifications.html",
v=v,
notifications=listing,
total=total,
page=page,
standalone=True,
render_replies=True,
)
@app.get("/notifications/posts")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)