forked from rDrama/rDrama
give jannies push notifs for chat
parent
959e662957
commit
c4e4a8d853
|
@ -106,14 +106,16 @@ def NOTIFY_USERS(text, v):
|
|||
return notify_users - bots
|
||||
|
||||
|
||||
def push_notif(uid, title, body, url):
|
||||
def push_notif(uids, title, body, url):
|
||||
if uids == {AEVANN_ID}: return
|
||||
|
||||
if VAPID_PUBLIC_KEY == DEFAULT_CONFIG_VALUE:
|
||||
return
|
||||
|
||||
if len(body) > PUSH_NOTIF_LIMIT:
|
||||
body = body[:PUSH_NOTIF_LIMIT] + "..."
|
||||
|
||||
subscriptions = g.db.query(PushSubscription.subscription_json).filter_by(user_id=uid).all()
|
||||
subscriptions = g.db.query(PushSubscription.subscription_json).filter(PushSubscription.user_id.in_(uids)).all()
|
||||
subscriptions = [x[0] for x in subscriptions]
|
||||
gevent.spawn(_push_notif_thread, subscriptions, title, body, url)
|
||||
|
||||
|
|
|
@ -104,6 +104,19 @@ def speak(data, v):
|
|||
muted[username] = duration
|
||||
|
||||
typing = []
|
||||
|
||||
if SITE == 'rdrama.net':
|
||||
title = f'New chat message from @{v.username}'
|
||||
notifbody = text
|
||||
url = f'{SITE_FULL}/chat'
|
||||
|
||||
admin_ids = [x[0] for x in g.db.query(User.id).filter(
|
||||
User.id != v.id,
|
||||
User.admin_level >= PERMS['CHAT'],
|
||||
).all()]
|
||||
|
||||
push_notif(admin_ids, title, notifbody, url)
|
||||
|
||||
return '', 204
|
||||
|
||||
@socketio.on('connect')
|
||||
|
|
|
@ -313,7 +313,7 @@ def comment(v:User):
|
|||
else:
|
||||
url = f'{SITE_FULL}/@{c.wall_user.username}/wall/comment/{c.id}?read=true#context'
|
||||
|
||||
push_notif(parent_user.id, title, notifbody, url)
|
||||
push_notif({parent_user.id}, title, notifbody, url)
|
||||
|
||||
vote = CommentVote(user_id=v.id,
|
||||
comment_id=c.id,
|
||||
|
|
|
@ -491,7 +491,7 @@ def message2(v:User, username:str):
|
|||
|
||||
url = f'{SITE_FULL}/notifications/messages'
|
||||
|
||||
push_notif(user.id, title, notifbody, url)
|
||||
push_notif({user.id}, title, notifbody, url)
|
||||
|
||||
return {"message": "Message sent!"}
|
||||
|
||||
|
@ -558,7 +558,7 @@ def messagereply(v:User):
|
|||
|
||||
url = f'{SITE_FULL}/notifications/messages'
|
||||
|
||||
push_notif(user_id, title, notifbody, url)
|
||||
push_notif({user_id}, title, notifbody, url)
|
||||
|
||||
top_comment = c.top_comment(g.db)
|
||||
|
||||
|
|
Loading…
Reference in New Issue