forked from rDrama/rDrama
make the gevent sequential
parent
9b09181e28
commit
3907a2f25f
|
@ -113,23 +113,23 @@ def push_notif(uid, title, body, url):
|
||||||
if len(body) > PUSH_NOTIF_LIMIT:
|
if len(body) > PUSH_NOTIF_LIMIT:
|
||||||
body = body[:PUSH_NOTIF_LIMIT] + "..."
|
body = body[:PUSH_NOTIF_LIMIT] + "..."
|
||||||
|
|
||||||
subscriptions = g.db.query(PushSubscription).filter_by(user_id=uid).all()
|
subscriptions = g.db.query(PushSubscription.subscription_json).filter_by(user_id=uid).all()
|
||||||
|
subscriptions = [x[0] for x in subscriptions]
|
||||||
|
gevent.spawn(_push_notif_thread, subscriptions, title, body, url)
|
||||||
|
|
||||||
|
|
||||||
|
def _push_notif_thread(subscriptions, title, body, url):
|
||||||
for subscription in subscriptions:
|
for subscription in subscriptions:
|
||||||
gevent.spawn(_push_notif_thread,
|
try:
|
||||||
subscription.subscription_json, title, body, url)
|
response = webpush(
|
||||||
|
subscription_info=json.loads(subscription),
|
||||||
|
data=json.dumps({
|
||||||
def _push_notif_thread(sub_json, title, body, url):
|
"title": title,
|
||||||
try:
|
"body": body,
|
||||||
response = webpush(
|
'url': url,
|
||||||
subscription_info=json.loads(sub_json),
|
'icon': f'{SITE_FULL}/icon.webp?v=1',
|
||||||
data=json.dumps({
|
}),
|
||||||
"title": title,
|
vapid_private_key=VAPID_PRIVATE_KEY,
|
||||||
"body": body,
|
vapid_claims={"sub": f"mailto:{EMAIL}"}
|
||||||
'url': url,
|
)
|
||||||
'icon': f'{SITE_FULL}/icon.webp?v=1',
|
except: continue
|
||||||
}),
|
|
||||||
vapid_private_key=VAPID_PRIVATE_KEY,
|
|
||||||
vapid_claims={"sub": f"mailto:{EMAIL}"}
|
|
||||||
)
|
|
||||||
except: pass
|
|
||||||
|
|
Loading…
Reference in New Issue