forked from GithubBackups/healthchecks
Handle Pushover emergency notifications
This commit is contained in:
parent
85c1f65887
commit
280bd6a2a2
@ -204,6 +204,9 @@ class Channel(models.Model):
|
||||
"html": 1,
|
||||
"priority": priority,
|
||||
}
|
||||
if priority == 2: # Emergency notification
|
||||
payload["retry"] = settings.PUSHOVER_EMERGENCY_RETRY_DELAY
|
||||
payload["expire"] = settings.PUSHOVER_EMERGENCY_EXPIRATION
|
||||
|
||||
url = "https://api.pushover.net/1/messages.json"
|
||||
r = requests.post(url, data=payload, timeout=5)
|
||||
|
@ -377,5 +377,9 @@ def add_pushover(request):
|
||||
})
|
||||
|
||||
else:
|
||||
ctx = {"page": "channels"}
|
||||
ctx = {
|
||||
"page": "channels",
|
||||
"po_retry_delay": td(seconds=settings.PUSHOVER_EMERGENCY_RETRY_DELAY),
|
||||
"po_expiration": td(seconds=settings.PUSHOVER_EMERGENCY_EXPIRATION),
|
||||
}
|
||||
return render(request, "integrations/add_pushover.html", ctx)
|
||||
|
@ -128,6 +128,8 @@ EMAIL_BACKEND = "djmail.backends.default.EmailBackend"
|
||||
# Pushover integration -- override these in local_settings
|
||||
PUSHOVER_API_TOKEN = None
|
||||
PUSHOVER_SUBSCRIPTION_URL = None
|
||||
PUSHOVER_EMERGENCY_RETRY_DELAY = 300
|
||||
PUSHOVER_EMERGENCY_EXPIRATION = 86400
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
|
@ -26,6 +26,14 @@
|
||||
<option value="-1">Low</option>
|
||||
<option value="0" selected>Normal</option>
|
||||
<option value="1">High</option>
|
||||
<option value="2"
|
||||
data-toggle="tooltip" data-placement="right"
|
||||
title="Emergency notifications will be repeated every
|
||||
{{po_retry_delay|hc_duration }} for at most
|
||||
{{ po_expiration|hc_duration }} until you
|
||||
acknowledge them.">
|
||||
Emergency
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -47,4 +55,7 @@
|
||||
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
{% endcompress %}
|
||||
<script>$(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'body'});
|
||||
})</script>
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user