From 713e03b66e9672743ef347936f5d03c5969063f2 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 14 Aug 2022 00:01:14 +0100 Subject: [PATCH] Make channel deletion endpoint accept JSON --- api/views.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/api/views.py b/api/views.py index 0ef1f5a..9f92aaf 100644 --- a/api/views.py +++ b/api/views.py @@ -435,11 +435,19 @@ class API(object): return dumps({"channels": channels}) - @app.route("/irc/network//channel//", methods=["DELETE"]) + @app.route("/irc/network//channel/", methods=["DELETE"]) @login_required - def irc_network_channel_part(self, request, net, channel): + def irc_network_channel_part(self, request, net): + try: + data = loads(request.content.read()) + except JSONDecodeError: + return "Invalid JSON" + if "channel" not in data: + return dumps({"success": False, "reason": "no channel specified."}) + channel = data["channel"] if net not in main.network.keys(): return dumps({"success": False, "reason": "no such net."}) + print("ABOUT TO PART", channel) parted = chankeep.partSingle(net, channel) if not parted: dumps({"success": False, "reason": "no channels matched."})