-
Notifications
You must be signed in to change notification settings - Fork 21
add webhook support #75
Copy link
Copy link
Open
Description
hey folks,
in addition to mail support, webhook support would be very nice.
this should be relatively easy to implement, just POST/GET to a url instead of sending the mail.
The url could simply be specified in the config, or as a parameter, the payload should be pretty much identical to the mail.
so e.g. with curl:
gotify GET
curl "https://gotify.domain.tld/message?token=ABASDASDASD" -F "title=btrfs-backup-data" -F "message=some cool text" -F "priority=5"
mattermost POST
curl --silent --output /dev/null -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE_TEXT\",\"channel\":\"$CHANNEL\"}" "https://mattermost.domain.tld/hooks/ABASDASDASD"
some little hacky test -> mail.py
import socket
import subprocess
from email.mime.text import MIMEText
import requests
def send(recipient, subject, content):
if recipient is None:
return
#if content is None or len(content) == 0:
# return
# Prepare mail
msg = MIMEText(content)
msg['From'] = '%s@%s' % ('btrfs-sxbackup', socket.getfqdn(socket.gethostname()))
msg['To'] = 'https://gotify.domain.tld/message?token=ABASDASDASD' #recipient
msg['Subject'] = subject
resp = requests.post(msg['To'], json={ "message": content,"priority": 2,"title": msg['From'] })
retcode = resp.status_code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels