Implement indexing into Apache Druid #1
39
api/views.py
39
api/views.py
|
@ -209,6 +209,45 @@ class API(object):
|
|||
network["records"] = userinfo.getNumWhoEntries(net)
|
||||
return dumps(network)
|
||||
|
||||
@app.route("/irc/network/<net>/edit/", methods=["POST"])
|
||||
@login_required
|
||||
def irc_network_edit(self, request, net):
|
||||
try:
|
||||
data = loads(request.content.read())
|
||||
except JSONDecodeError:
|
||||
return "Invalid JSON"
|
||||
if net not in main.network.keys():
|
||||
return dumps(False)
|
||||
inst = main.network[net]
|
||||
for item in data:
|
||||
if item == "auth":
|
||||
auth = data[item][0]
|
||||
if auth not in ["sasl", "ns", "none"]:
|
||||
return dumps({"success": False, "reason": "invalid auth."})
|
||||
elif item == "host":
|
||||
host = data[item][0]
|
||||
elif item == "last":
|
||||
last = data[item][0]
|
||||
if not last.isdigit():
|
||||
return dumps({"success": False, "reason": "invalid last: not a number."})
|
||||
elif item == "port":
|
||||
port = data[item][0]
|
||||
if not port.isdigit():
|
||||
return dumps({"success": False, "reason": "invalid port: not a number."})
|
||||
port = int(port)
|
||||
elif item == "security":
|
||||
security = data[item][0]
|
||||
if security not in ["ssl", "plain"]:
|
||||
return dumps({"success": False, "reason": "invalid security."})
|
||||
inst.auth = auth
|
||||
inst.host = host
|
||||
inst.last = last
|
||||
inst.port = port
|
||||
inst.security = security
|
||||
main.saveConf("network")
|
||||
|
||||
return dumps({"success": True})
|
||||
|
||||
@app.route("/irc/network/<net>/relays/", methods=["POST"])
|
||||
@login_required
|
||||
def irc_network_relays(self, request, net):
|
||||
|
|
Loading…
Reference in New Issue