Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
LOG.error('MS Teams: ERROR - Template(TEXT_FMT) render failed: %s', e)
return
else:
text = alert.text
LOG.debug('MS Teams payload: %s', summary)
try:
if MS_TEAMS_PAYLOAD:
# Use requests.post to send raw json message card
LOG.debug("MS Teams sending(json payload) POST to %s", MS_TEAMS_WEBHOOK_URL)
r = requests.post(MS_TEAMS_WEBHOOK_URL, data=card_json, timeout=MS_TEAMS_DEFAULT_TIMEOUT)
LOG.debug('MS Teams response: %s / %s' % (r.status_code, r.text))
else:
# Use pymsteams to send card
msTeamsMessage = pymsteams.connectorcard(hookurl=MS_TEAMS_WEBHOOK_URL, http_timeout=MS_TEAMS_DEFAULT_TIMEOUT)
msTeamsMessage.title(summary)
msTeamsMessage.text(text)
msTeamsMessage.addLinkButton("Open in Alerta", url)
msTeamsMessage.color(color)
msTeamsMessage.send()
except Exception as e:
raise RuntimeError("MS Teams: ERROR - %s", e)