Unverified Commit 7c6c1d16 authored by Dan Jones's avatar Dan Jones
Browse files

refactor: change send notify to parse posted json

parent 40590158
...@@ -17,18 +17,19 @@ class Notify(Resource): ...@@ -17,18 +17,19 @@ class Notify(Resource):
self.clients = json.load(clients_file) self.clients = json.load(clients_file)
def post(self): def post(self):
errors = self.schema.validate(request.args) args = request.get_json()
errors = self.schema.validate(args)
if errors: if errors:
abort(400, message=str(errors)) abort(400, message=str(errors))
messages = [] messages = []
allow = False allow = False
body = request.args.get("body") body = args.get("body")
client_id = request.args.get("client_id") client_id = args.get("client_id")
notify_queue = client_id + "-notify" notify_queue = client_id + "-notify"
if client_id in self.clients: if client_id in self.clients:
client = self.clients.get(client_id) client = self.clients.get(client_id)
if request.args.get("secret") == client.get("secret"): if args.get("secret") == client.get("secret"):
allow = True allow = True
if allow: if allow:
......
...@@ -18,19 +18,20 @@ class Send(Resource): ...@@ -18,19 +18,20 @@ class Send(Resource):
self.clients = json.load(clients_file) self.clients = json.load(clients_file)
def post(self): def post(self):
errors = self.schema.validate(request.args) args = request.get_json()
errors = self.schema.validate(args)
if errors: if errors:
abort(400, message=str(errors)) abort(400, message=str(errors))
messages = [] messages = []
allow = False allow = False
body = request.args.get("body") body = args.get("body")
topic = request.args.get("topic") topic = args.get("topic")
client_id = request.args.get("client_id") client_id = args.get("client_id")
outbox_queue = client_id + "-outbox" outbox_queue = client_id + "-outbox"
if client_id in self.clients: if client_id in self.clients:
client = self.clients.get(client_id) client = self.clients.get(client_id)
if request.args.get("secret") == client.get("secret"): if args.get("secret") == client.get("secret"):
allow = True allow = True
if allow: if allow:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment