ready for build
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import request
|
||||
from flask import request, render_template
|
||||
from flask_restful import Resource
|
||||
from utils.error_handler import error_handler
|
||||
from app.app import app
|
||||
@@ -11,11 +11,12 @@ class BarkResource(Resource):
|
||||
try:
|
||||
data = Munch.fromDict(request.get_json(silent=True))
|
||||
app.logger.debug(data)
|
||||
config = Munch.fromDict(app.config)
|
||||
content = {
|
||||
config = Munch.fromDict(app.config["APP_CONFIG"])
|
||||
|
||||
content = Munch.fromDict({
|
||||
'title': config.title.firing if data.status == 'firing' else config.title.resolved if data.status == 'resolved' else config.title.default,
|
||||
'category': 'category'
|
||||
}
|
||||
})
|
||||
|
||||
# TODO: alertmanager message to bark content.
|
||||
'''
|
||||
@@ -43,10 +44,11 @@ class BarkResource(Resource):
|
||||
]
|
||||
}
|
||||
'''
|
||||
content.body = app.jinja_environment.get_template(config.template_file).render(data)
|
||||
content.body = render_template(config.template_file, **data)
|
||||
|
||||
app.logger.debug(content.body)
|
||||
for to in config.to:
|
||||
content['device_key'] = to
|
||||
content.device_key = to
|
||||
response = requests.post(
|
||||
url = config.bark_api,
|
||||
headers = {
|
||||
|
Reference in New Issue
Block a user