Implement automatic provisioning
This commit is contained in:
parent
b72d3d67a1
commit
864f0904f5
20
api/views.py
20
api/views.py
|
@ -5,7 +5,7 @@ from klein import Klein
|
|||
from twisted.web.server import Request
|
||||
|
||||
import main
|
||||
from modules import chankeep, userinfo
|
||||
from modules import chankeep, provision, userinfo
|
||||
from utils.logging.log import warn
|
||||
|
||||
|
||||
|
@ -396,10 +396,26 @@ class API(object):
|
|||
if alias not in main.alias.keys():
|
||||
return dumps({"success": False, "reason": "alias does not exist."})
|
||||
if fields:
|
||||
main.alias[alias] = fields
|
||||
for field in fields:
|
||||
if field in main.alias[alias]:
|
||||
main.alias[alias][field] = fields[field]
|
||||
if "emails" in fields:
|
||||
if not fields["emails"]:
|
||||
main.alias[alias]["emails"] = []
|
||||
main.saveConf("alias")
|
||||
|
||||
return dumps({"success": True})
|
||||
|
||||
@app.route("/irc/auto/<net>/", methods=["POST"])
|
||||
@login_required
|
||||
def irc_auto_network(self, request, net):
|
||||
print(repr(main.network[net].relays.keys()))
|
||||
if net not in main.network.keys():
|
||||
return dumps({"success": False, "reason": "no such net."})
|
||||
if 1 in main.network[net].relays.keys():
|
||||
return dumps({"success": False, "reason": f"First relay exists on {net}"})
|
||||
num, alias = main.network[net].add_relay(1)
|
||||
provision.provisionRelay(num, net)
|
||||
main.saveConf("network")
|
||||
|
||||
return dumps({"success": True, f"message": "Created relay {num} with alias {alias} on {net}"})
|
||||
|
|
|
@ -63,7 +63,6 @@ def provisionAuthenticationData(num, nick, network, security, auth, password):
|
|||
|
||||
def provisionRelay(num, network): # provision user and network data
|
||||
aliasObj = main.alias[num]
|
||||
print("ALIASOBJ FALUES", aliasObj.values())
|
||||
# alias = aliasObj["nick"]
|
||||
provisionUserNetworkData(
|
||||
num,
|
||||
|
|
Loading…
Reference in New Issue