From 7c6c1d167d48a40737fd3640acb8c2fd532944c5 Mon Sep 17 00:00:00 2001
From: Dan Jones <dan.jones@noc.ac.uk>
Date: Wed, 16 Nov 2022 17:19:51 +0000
Subject: [PATCH] refactor: change send notify to parse posted json

---
 endpoints/notify.py |  9 +++++----
 endpoints/send.py   | 11 ++++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/endpoints/notify.py b/endpoints/notify.py
index 0ebb0d1..3e0c552 100644
--- a/endpoints/notify.py
+++ b/endpoints/notify.py
@@ -17,18 +17,19 @@ class Notify(Resource):
             self.clients = json.load(clients_file)
 
     def post(self):
-        errors = self.schema.validate(request.args)
+        args = request.get_json()
+        errors = self.schema.validate(args)
         if errors:
             abort(400, message=str(errors))
 
         messages = []
         allow = False
-        body = request.args.get("body")
-        client_id = request.args.get("client_id")
+        body = args.get("body")
+        client_id = args.get("client_id")
         notify_queue = client_id + "-notify"
         if client_id in self.clients:
             client = self.clients.get(client_id)
-            if request.args.get("secret") == client.get("secret"):
+            if args.get("secret") == client.get("secret"):
                 allow = True
 
         if allow:
diff --git a/endpoints/send.py b/endpoints/send.py
index 119c67b..d755186 100644
--- a/endpoints/send.py
+++ b/endpoints/send.py
@@ -18,19 +18,20 @@ class Send(Resource):
             self.clients = json.load(clients_file)
 
     def post(self):
-        errors = self.schema.validate(request.args)
+        args = request.get_json()
+        errors = self.schema.validate(args)
         if errors:
             abort(400, message=str(errors))
 
         messages = []
         allow = False
-        body = request.args.get("body")
-        topic = request.args.get("topic")
-        client_id = request.args.get("client_id")
+        body = args.get("body")
+        topic = args.get("topic")
+        client_id = args.get("client_id")
         outbox_queue = client_id + "-outbox"
         if client_id in self.clients:
             client = self.clients.get(client_id)
-            if request.args.get("secret") == client.get("secret"):
+            if args.get("secret") == client.get("secret"):
                 allow = True
 
         if allow:
-- 
GitLab