From 2e57e0930a1051631d9ba58e527e3730862f538f Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 13 Aug 2022 20:51:31 +0100 Subject: [PATCH] Implement API endpoint for provisioning relays --- api/views.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/views.py b/api/views.py index 2137f52..2e38a2a 100644 --- a/api/views.py +++ b/api/views.py @@ -395,6 +395,20 @@ class API(object): main.saveConf("network") return dumps({"success": True}) + @app.route("/irc/network///provision/", methods=["POST"]) + @login_required + def irc_network_relay_provision(self, request, net, num): + if net not in main.network.keys(): + return dumps({"success": False, "reason": "no such net."}) + if not num.isdigit(): + return dumps({"success": False, "reason": "invalid num: not a number."}) + num = int(num) + net_inst = main.network[net] + if num not in net_inst.relays: + return dumps({"success": False, "reason": "network does not have this relay."}) + provision.provisionRelay(num, net) + return dumps({"success": True}) + @app.route("/irc/network//channels/", methods=["POST"]) @login_required def irc_network_channels(self, request, net):