From 2058610f1e9d640aee9fe127adc9bf114386855b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 16 Jan 2022 04:09:20 +0200 Subject: [PATCH] bbb --- files/routes/users.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/files/routes/users.py b/files/routes/users.py index 6c8ff12ef..e8b4e1cf3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -500,6 +500,34 @@ def messagereply(v): notif = Notification(comment_id=new_comment.id, user_id=user_id) g.db.add(notif) + + if len(message) > 100: notifbody = message[:100] + '...' + else: notifbody = message + + beams_client.publish_to_interests( + interests=[f'{request.host}{user_id}'], + publish_body={ + 'web': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + 'deep_link': f'https://{site}/notifications', + 'icon': f'https://{request.host}/assets/images/{SITE_NAME}/icon.webp', + } + }, + 'fcm': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + }, + 'data': { + 'url': 'notifications', + } + } + }, + ) + + if new_comment.top_comment.sentto == 0: admins = g.db.query(User).filter(User.admin_level > 2, User.id != v.id, User.id != user_id).all() for admin in admins: