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
|
# Retrieving the subscription information from the incoming request
|
||||||
content = request.json
|
content = request.json
|
||||||
endpoint = content['endpoint']
|
endpoint = content['endpoint']
|
||||||
p256dh = content['p256dh']
|
p256dh = content['keys']['p256dh']
|
||||||
auth = content['auth']
|
auth = content['keys']['auth']
|
||||||
|
|
||||||
# Looking up the subscription in the database
|
# Looking up the subscription in the database
|
||||||
subscription = Subscription.query.filter_by(endpoint=endpoint, p256dh=p256dh, auth=auth).first()
|
subscription = Subscription.query.filter_by(endpoint=endpoint, p256dh=p256dh, auth=auth).first()
|
||||||
@@ -449,10 +449,11 @@ class WebPushService():
|
|||||||
"auth": subscription.auth
|
"auth": subscription.auth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vapid_key = VAPIDKey.query.first()
|
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)
|
result = WebPushService._send_push_notification(subscription_info, {"title": "Test Notification", "message": "This is a test notification"}, vapid_key.private_key)
|
||||||
return jsonify(result)
|
return jsonify(result)
|
||||||
else:
|
else:
|
||||||
return jsonify({"success": False, "message": "Subscription not found"}), 404
|
return jsonify({"success": False, "message": "Subscription not found"}), 404
|
||||||
|
|
||||||
|
|
||||||
web_push_service = WebPushService(app, "app")
|
web_push_service = WebPushService(app, "app")
|
||||||
|
|||||||
Reference in New Issue
Block a user