Make channel deletion endpoint accept JSON
This commit is contained in:
parent
a0761ff1ae
commit
713e03b66e
12
api/views.py
12
api/views.py
|
@ -435,11 +435,19 @@ class API(object):
|
||||||
|
|
||||||
return dumps({"channels": channels})
|
return dumps({"channels": channels})
|
||||||
|
|
||||||
@app.route("/irc/network/<net>/channel/<channel>/", methods=["DELETE"])
|
@app.route("/irc/network/<net>/channel/", methods=["DELETE"])
|
||||||
@login_required
|
@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():
|
if net not in main.network.keys():
|
||||||
return dumps({"success": False, "reason": "no such net."})
|
return dumps({"success": False, "reason": "no such net."})
|
||||||
|
print("ABOUT TO PART", channel)
|
||||||
parted = chankeep.partSingle(net, channel)
|
parted = chankeep.partSingle(net, channel)
|
||||||
if not parted:
|
if not parted:
|
||||||
dumps({"success": False, "reason": "no channels matched."})
|
dumps({"success": False, "reason": "no channels matched."})
|
||||||
|
|
Loading…
Reference in New Issue