Implement automatic provisioning
This commit is contained in:
parent
0dedb545f0
commit
e8870e95e7
20
api/views.py
20
api/views.py
|
@ -5,7 +5,7 @@ from klein import Klein
|
||||||
from twisted.web.server import Request
|
from twisted.web.server import Request
|
||||||
|
|
||||||
import main
|
import main
|
||||||
from modules import chankeep, userinfo
|
from modules import chankeep, provision, userinfo
|
||||||
from utils.logging.log import warn
|
from utils.logging.log import warn
|
||||||
|
|
||||||
|
|
||||||
|
@ -396,10 +396,26 @@ class API(object):
|
||||||
if alias not in main.alias.keys():
|
if alias not in main.alias.keys():
|
||||||
return dumps({"success": False, "reason": "alias does not exist."})
|
return dumps({"success": False, "reason": "alias does not exist."})
|
||||||
if fields:
|
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 "emails" in fields:
|
||||||
if not fields["emails"]:
|
if not fields["emails"]:
|
||||||
main.alias[alias]["emails"] = []
|
main.alias[alias]["emails"] = []
|
||||||
main.saveConf("alias")
|
main.saveConf("alias")
|
||||||
|
|
||||||
return dumps({"success": True})
|
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
|
def provisionRelay(num, network): # provision user and network data
|
||||||
aliasObj = main.alias[num]
|
aliasObj = main.alias[num]
|
||||||
print("ALIASOBJ FALUES", aliasObj.values())
|
|
||||||
# alias = aliasObj["nick"]
|
# alias = aliasObj["nick"]
|
||||||
provisionUserNetworkData(
|
provisionUserNetworkData(
|
||||||
num,
|
num,
|
||||||
|
|
Loading…
Reference in New Issue