mirror of
https://github.com/laurivosandi/certidude
synced 2024-12-23 00:25:18 +00:00
Push server fixes
This commit is contained in:
parent
7012f5b365
commit
c33da46f19
@ -169,7 +169,7 @@ def delete_request(common_name):
|
|||||||
push.publish("request-deleted", request.common_name)
|
push.publish("request-deleted", request.common_name)
|
||||||
|
|
||||||
# Write empty certificate to long-polling URL
|
# Write empty certificate to long-polling URL
|
||||||
requests.delete(config.PUSH_PUBLISH % request.common_name,
|
requests.delete(config.PUSH_PUBLISH % request.fingerprint(),
|
||||||
headers={"User-Agent": "Certidude API"})
|
headers={"User-Agent": "Certidude API"})
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,15 +16,18 @@ def publish(event_type, event_data):
|
|||||||
event_data = json.dumps(event_data, cls=MyEncoder)
|
event_data = json.dumps(event_data, cls=MyEncoder)
|
||||||
|
|
||||||
url = config.PUSH_PUBLISH % config.PUSH_TOKEN
|
url = config.PUSH_PUBLISH % config.PUSH_TOKEN
|
||||||
click.echo("Publishing %s event %s on %s" % (event_type, event_data, url))
|
click.echo("Publishing %s event '%s' on %s" % (event_type, event_data, url))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
notification = requests.post(
|
notification = requests.post(
|
||||||
url,
|
url,
|
||||||
data=event_data,
|
data=event_data,
|
||||||
headers={"X-EventSource-Event": event_type, "User-Agent": "Certidude API"})
|
headers={"X-EventSource-Event": event_type, "User-Agent": "Certidude API"})
|
||||||
|
if notification.status_code != requests.codes.created:
|
||||||
|
click.echo("Failed to submit event to push server, server responded %d, expected %d" % (
|
||||||
|
notification.status_code, requests.codes.created))
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
click.echo("Failed to submit event to push server: %s" % repr(event_data))
|
click.echo("Failed to submit event to push server, connection error")
|
||||||
|
|
||||||
class PushLogHandler(logging.Handler):
|
class PushLogHandler(logging.Handler):
|
||||||
"""
|
"""
|
||||||
|
@ -67,6 +67,7 @@ function onRequestSubmitted(e) {
|
|||||||
url: "/api/request/" + e.data + "/",
|
url: "/api/request/" + e.data + "/",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(request, status, xhr) {
|
success: function(request, status, xhr) {
|
||||||
|
onRequestDeleted(e); // Delete any existing ones just in case
|
||||||
$("#pending_requests").prepend(
|
$("#pending_requests").prepend(
|
||||||
nunjucks.render('views/request.html', { request: request }));
|
nunjucks.render('views/request.html', { request: request }));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user