diff --git a/api/views.py b/api/views.py index 9f92aaf..788a0dc 100644 --- a/api/views.py +++ b/api/views.py @@ -325,15 +325,14 @@ class API(object): to_append["nick"] = main.IRCPool[name].nickname to_append["conn"] = main.IRCPool[name].isconnected to_append["limit"] = main.IRCPool[name].chanlimit - to_append["auth"] = main.IRCPool[name].authenticated + to_append["authed"] = main.IRCPool[name].authenticated else: to_append["chans"] = 0 to_append["nick"] = None to_append["conn"] = False to_append["limit"] = None - to_append["auth"] = None + to_append["authed"] = None relays.append(to_append) - return dumps({"relays": relays}) @app.route("/irc/network///", methods=["POST"]) @@ -435,9 +434,10 @@ class API(object): return dumps({"channels": channels}) + # API version @app.route("/irc/network//channel/", methods=["DELETE"]) @login_required - def irc_network_channel_part(self, request, net): + def irc_network_channel_part_api(self, request, net): try: data = loads(request.content.read()) except JSONDecodeError: @@ -447,12 +447,29 @@ class API(object): 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."}) return dumps({"success": True, "relays": parted}) + # API version + @app.route("/irc/network//channel/", methods=["PUT"]) + @login_required + def irc_network_channel_join_api(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."}) + joined = chankeep.joinSingle(net, channel) + if not joined: + return dumps({"success": False, "reason": "could not allocate channel to relay."}) + return dumps({"success": True, "relays": joined}) + @app.route("/irc/network//channel//", methods=["PUT"]) @login_required def irc_network_channel_join(self, request, net, channel):