add more logging
This commit is contained in:
6
app.py
6
app.py
@@ -226,7 +226,8 @@ class WebPushService():
|
||||
"auth": subscription.auth
|
||||
}
|
||||
}
|
||||
WebPushService._send_push_notification(subscription_info, message, vapid_key)
|
||||
result = WebPushService._send_push_notification(subscription_info, message, vapid_key)
|
||||
print(f"Result from sub {subscription.id}: success={result['success']} text={result['message']}", flush=True)
|
||||
print(f"{now} - Finished sending {len(all_subscriptions)} subscriptions.", flush=True)
|
||||
|
||||
# Sleeping for 24 hours before sending the next set of notifications
|
||||
@@ -470,8 +471,11 @@ class WebPushService():
|
||||
{"title": title, "message": message},
|
||||
vapid_key
|
||||
)
|
||||
|
||||
print(f"Test sent: {result['success']}")
|
||||
return jsonify(success=result["success"], message=result["message"])
|
||||
else:
|
||||
print(f"Test failed due to missing subscription. Request: {json.dumps(content)}")
|
||||
return jsonify({"success": False, "message": "Subscription not found"}), 404
|
||||
|
||||
|
||||
|
||||
@@ -75,13 +75,14 @@ if len(sys.argv) > 2:
|
||||
try:
|
||||
#print(str(subscription_info))
|
||||
#sys.exit(0)
|
||||
result = webpush(
|
||||
response = webpush(
|
||||
subscription_info,
|
||||
data,
|
||||
vapid_private_key=private_key_base64,
|
||||
vapid_claims={"sub": "mailto:info@timesafari.app"}
|
||||
)
|
||||
print(f"Result from remote service: {result}")
|
||||
print(f"Response: {response}")
|
||||
print(f"Full response: {response.__dict__}")
|
||||
# log the .reason from Apple
|
||||
# https://developer.apple.com/documentation/usernotifications/sending_web_push_notifications_in_web_apps_and_browsers#3994594
|
||||
except WebPushException as ex:
|
||||
|
||||
Reference in New Issue
Block a user