Skip to content

Commit

Permalink
[Chore #133846511] Add nag email transport function
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilbert Gathara committed Dec 14, 2016
1 parent 4f4a442 commit 14bcfd4
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions hc/api/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from six.moves.urllib.parse import quote

from hc.lib import emails
from hc.api import models


def tmpl(template_name, **ctx):
Expand All @@ -14,9 +15,8 @@ def tmpl(template_name, **ctx):


class Transport(object):
def __init__(self, channel, check):
def __init__(self, channel):
self.channel = channel
self.check = check

def notify(self, check):
""" Send notification about current status of the check.
Expand Down Expand Up @@ -52,25 +52,13 @@ def notify(self, check):
if not check.user.profile.team_access_allowed:
show_upgrade_note = True

### if check has nag enabled, send a nag email, else send normal alert
if self.check.nag_enabled:
ctx = {
"check": check,
"checks": self.checks(),
"now": timezone.now(),
"nag_after": self.check.nag_after,
"total_nags": self.check.n_nags,
"show_upgrade_note": show_upgrade_note
}
emails.nag(self.channel.value, ctx)
else:
ctx = {
"check": check,
"checks": self.checks(),
"now": timezone.now(),
"show_upgrade_note": show_upgrade_note
}
emails.alert(self.channel.value, ctx)
ctx = {
"check": check,
"checks": self.checks(),
"now": timezone.now(),
"show_upgrade_note": show_upgrade_note
}
emails.alert(self.channel.value, ctx)


class HttpTransport(Transport):
Expand Down

0 comments on commit 14bcfd4

Please sign in to comment.