Browse Source

Handle Pushover emergency notifications

pull/12/head
Thomas Jost 9 years ago
parent
commit
280bd6a2a2
4 changed files with 21 additions and 1 deletions
  1. +3
    -0
      hc/api/models.py
  2. +5
    -1
      hc/front/views.py
  3. +2
    -0
      hc/settings.py
  4. +11
    -0
      templates/integrations/add_pushover.html

+ 3
- 0
hc/api/models.py View File

@ -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)


+ 5
- 1
hc/front/views.py View File

@ -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)

+ 2
- 0
hc/settings.py View File

@ -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 *


+ 11
- 0
templates/integrations/add_pushover.html View File

@ -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…
Cancel
Save