From 7012caa6ef11168223539997cb4f8670fbaf5f17 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 12 Jan 2024 19:15:15 +0200 Subject: [PATCH] on rdrama, extend hole and ping group notifs to everyone active in the past week --- files/helpers/config/const.py | 2 ++ files/routes/groups.py | 7 ++++--- files/routes/holes.py | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 336596453..ec16f680f 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -150,6 +150,8 @@ if SITE_NAME == 'rDrama': patron = "Paypig" + PERMS['NOTIFICATIONS_HOLE_CREATION'] = 0 + TAGLINES = ( "largest online LGBTQ+ club", "largest online furfest", diff --git a/files/routes/groups.py b/files/routes/groups.py index 7515afb4c..139324ca1 100644 --- a/files/routes/groups.py +++ b/files/routes/groups.py @@ -54,9 +54,10 @@ def create_group(v): g.db.flush() #Necessary, to make linkfying the ping group in the notification work - admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id)] - for admin in admins: - send_repeatable_notification(admin, f":!marseyparty: !{group} has been created by @{v.username} :marseyparty:") + t = time.time() - 604800 + notified_users = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id, User.last_active > t)] + for user in notified_users: + send_repeatable_notification(user, f":!marseyparty: !{group} has been created by @{v.username} :marseyparty:") return {"message": f"!{group} created successfully!"} diff --git a/files/routes/holes.py b/files/routes/holes.py index 67006d27e..eb2081e8a 100644 --- a/files/routes/holes.py +++ b/files/routes/holes.py @@ -389,9 +389,10 @@ def create_sub2(v): mod = Mod(user_id=v.id, hole=hole.name) g.db.add(mod) - admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id)] - for admin in admins: - send_repeatable_notification(admin, f":!marseyparty: /h/{hole} has been created by @{v.username} :marseyparty:") + t = time.time() - 604800 + notified_users = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id, User.last_active > t)] + for user in notified_users: + send_repeatable_notification(user, f":!marseyparty: /h/{hole} has been created by @{v.username} :marseyparty:") return redirect(f"/h/{hole}")