aboutsummaryrefslogtreecommitdiff
path: root/app/utils.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-07-09 04:16:45 +0100
committerrubenwardy <rw@rubenwardy.com>2020-07-09 04:16:45 +0100
commitd0aecd0ee59663ac81733ff8087847106c7ba4cc (patch)
tree6a306fc1d4d85fb074241d18c1245301e51046e1 /app/utils.py
parent307b8f8ddea30cb44ad02170b40dd3c0d1d3d6c3 (diff)
downloadcheatdb-d0aecd0ee59663ac81733ff8087847106c7ba4cc.tar.xz
Rename triggerNotif to addNotification, add array support
Diffstat (limited to 'app/utils.py')
-rw-r--r--app/utils.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/utils.py b/app/utils.py
index d6e6eaa..67b4015 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -188,12 +188,19 @@ def is_package_page(f):
return decorated_function
-def triggerNotif(owner, causer, title, url):
- if owner.rank.atLeast(UserRank.NEW_MEMBER) and owner != causer:
- Notification.query.filter_by(user=owner, causer=causer, title=title, url=url).delete()
- notif = Notification(owner, causer, title, url)
+
+def addNotification(target, causer, title, url):
+ if not isinstance(target, User):
+ for x in target:
+ addNotification(x, causer, title, url)
+ return
+
+ if target.rank.atLeast(UserRank.NEW_MEMBER) and target != causer:
+ Notification.query.filter_by(user=target, causer=causer, title=title, url=url).delete()
+ notif = Notification(target, causer, title, url)
db.session.add(notif)
+
def clearNotifications(url):
if current_user.is_authenticated:
Notification.query.filter_by(user=current_user, url=url).delete()