Created
May 21, 2020 08:18
-
-
Save garanews/48998e4076a9ca3e271bda8c39188418 to your computer and use it in GitHub Desktop.
The Hive webhook email alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from flask_mail import Mail | |
import json | |
from flask_mail import Message | |
app = Flask(__name__) | |
app.config['MAIL_SERVER'] = "1.2.3.4" | |
app.config['MAIL_PORT'] = "25" | |
app.config['MAIL_USE_TLS'] = "" | |
app.config['MAIL_USE_SSL'] = "" | |
app.config['MAIL_DEBUG'] = False | |
app.config['MAIL_USERNAME'] = "" | |
app.config['MAIL_PASSWORD'] = "" | |
app.config['MAIL_DEFAULT_SENDER'] = "" | |
app.config['MAIL_MAX_EMAILS'] = "" | |
app.config['MAIL_SUPPRESS_SEND'] = "" | |
app.config['MAIL_ASCII_ATTACHMENTS'] = "" | |
mail = Mail(app) | |
@app.route('/',methods=['POST']) | |
def foo(): | |
data = json.loads(request.data) | |
if data['objectType'] == 'case': | |
msg = Message(data['operation'] + " - case: " + str(data['object']['caseId']) + " - " + data['object']['title'], sender="[email protected]", recipients=["[email protected]"]) | |
msg.body = data['details']['description'] | |
msg.html = "<b>" + data['details']['description'] + "</b>" | |
mail.send(msg) | |
return "OK" | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment