aboutsummaryrefslogtreecommitdiff
path: root/gerboweb/deploy
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2020-01-26 22:38:02 +0100
committerjaseg <code@jaseg.net>2020-01-26 22:38:02 +0100
commit0e9d0e8efab79f527507f8c161daaad44cfd1b56 (patch)
tree4a19342ffc419a65418999b5e8d5e889ef396ead /gerboweb/deploy
parent0614974bedf0f44845e7a4062881284bd6fe6c0f (diff)
downloadgerbolyze-0e9d0e8efab79f527507f8c161daaad44cfd1b56.tar.gz
gerbolyze-0e9d0e8efab79f527507f8c161daaad44cfd1b56.tar.bz2
gerbolyze-0e9d0e8efab79f527507f8c161daaad44cfd1b56.zip
deploy/klingel: Add classification support
Diffstat (limited to 'gerboweb/deploy')
-rw-r--r--gerboweb/deploy/notification_proxy.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/gerboweb/deploy/notification_proxy.py b/gerboweb/deploy/notification_proxy.py
index fcef50f..117f8e1 100644
--- a/gerboweb/deploy/notification_proxy.py
+++ b/gerboweb/deploy/notification_proxy.py
@@ -34,10 +34,10 @@ with db as conn:
mail_routes = {}
-def mail_route(name, receiver, subject, secret):
+def mail_route(name, receiver, secret):
def wrap(func):
global routes
- mail_routes[name] = (receiver, subject, func, secret)
+ mail_routes[name] = (receiver, func, secret)
return func
return wrap
@@ -109,9 +109,10 @@ def authenticate(route_name, secret, clock_delta_tolerance:'s'=120):
return msg_time, payload['scope'], payload['d']
-@mail_route('klingel', 'computerstuff@jaseg.de', 'It rang!', app.config['SECRET_KLINGEL'])
-def klingel(rms=None, capture=None, **kwargs):
- return f'rms={rms}\ncapture={capture}\nextra_args={kwargs}'
+@mail_route('klingel', 'computerstuff@jaseg.de', app.config['SECRET_KLINGEL'])
+def klingel(classification='somewhere', rms=None, capture=None, **kwargs):
+ return (f'It rang {classification}!',
+ f'rms={rms}\ncapture={capture}\nextra_args={kwargs}')
def send_mail(route_name, receiver, subject, body):
@@ -134,13 +135,16 @@ def send_mail(route_name, receiver, subject, body):
@app.route('/v1/notify/<route_name>', methods=['POST'])
def notify(route_name):
- receiver, notify_subject, func, secret = mail_routes[route_name]
+ receiver, func, secret = mail_routes[route_name]
msg_time, scope, kwargs = authenticate(route_name, secret)
if scope == 'default':
# Exceptions will yield a 500 error
- body = func(**kwargs)
- send_mail(route_name, receiver, notify_subject, body or 'empty message')
+ subject, body = func(**kwargs)
+ send_mail(route_name, receiver, subject, body or 'empty message')
+
+ elif scope == 'info':
+ send_mail(route_name, receiver, f'System info: {kwargs["info_msg"]}', f'Logged data: {kwargs}')
elif scope == 'boot':
formatted = datetime.utcfromtimestamp(msg_time).isoformat()