fix some things that are wrong in the data structures
This commit is contained in:
9
app.py
9
app.py
@@ -434,8 +434,8 @@ class WebPushService():
|
||||
# Retrieving the subscription information from the incoming request
|
||||
content = request.json
|
||||
endpoint = content['endpoint']
|
||||
p256dh = content['p256dh']
|
||||
auth = content['auth']
|
||||
p256dh = content['keys']['p256dh']
|
||||
auth = content['keys']['auth']
|
||||
|
||||
# Looking up the subscription in the database
|
||||
subscription = Subscription.query.filter_by(endpoint=endpoint, p256dh=p256dh, auth=auth).first()
|
||||
@@ -449,10 +449,11 @@ class WebPushService():
|
||||
"auth": subscription.auth
|
||||
}
|
||||
}
|
||||
vapid_key = VAPIDKey.query.first()
|
||||
result = WebPushService._send_push_notification(subscription_info, {"title": "Test Notification", "message": "This is a test notification"}, vapid_key)
|
||||
vapid_key = VAPIDKey.query.filter_by(id = subscription.vapid_key_id)
|
||||
result = WebPushService._send_push_notification(subscription_info, {"title": "Test Notification", "message": "This is a test notification"}, vapid_key.private_key)
|
||||
return jsonify(result)
|
||||
else:
|
||||
return jsonify({"success": False, "message": "Subscription not found"}), 404
|
||||
|
||||
|
||||
web_push_service = WebPushService(app, "app")
|
||||
|
||||
Reference in New Issue
Block a user