Fix provisioning with emails
This commit is contained in:
parent
f88e6dec5a
commit
e0f86ec853
|
@ -5,7 +5,7 @@ from twisted.internet import reactor
|
|||
import modules.regproc
|
||||
|
||||
|
||||
def provisionUserNetworkData(num, nick, altnick, ident, realname, network, host, port, security, auth, password):
|
||||
def provisionUserNetworkData(num, nick, altnick, emails, ident, realname, network, host, port, security, auth, password):
|
||||
commands = {}
|
||||
stage2commands = {}
|
||||
stage2commands["status"] = []
|
||||
|
|
|
@ -3,7 +3,7 @@ from modules import provision
|
|||
from utils.logging.log import *
|
||||
from utils.logging.debug import *
|
||||
from copy import deepcopy
|
||||
|
||||
from random import choice
|
||||
|
||||
def needToRegister(net):
|
||||
inst = selectInst(net)
|
||||
|
@ -28,16 +28,23 @@ def selectInst(net):
|
|||
def substitute(net, num, token=None):
|
||||
inst = selectInst(net)
|
||||
alias = main.alias[num]
|
||||
if "emails" in inst:
|
||||
# First priority is explicit email lists
|
||||
email = choice(alias["emails"])
|
||||
elif "domains" in inst:
|
||||
domain = choice(inst["domains"])
|
||||
email = f"{alias['nickname']}@{domain}"
|
||||
print("Constructed email: {email}")
|
||||
nickname = alias["nick"]
|
||||
username = nickname + "/" + net
|
||||
password = main.network[net].aliases[num]["password"]
|
||||
inst["email"] = inst["email"].replace("{nickname}", nickname)
|
||||
#inst["email"] = inst["email"].replace("{nickname}", nickname)
|
||||
for i in inst.keys():
|
||||
if not isinstance(inst[i], str):
|
||||
continue
|
||||
inst[i] = inst[i].replace("{nickname}", nickname)
|
||||
inst[i] = inst[i].replace("{password}", password)
|
||||
inst[i] = inst[i].replace("{email}", inst["email"])
|
||||
inst[i] = inst[i].replace("{email}", email)
|
||||
if token:
|
||||
inst[i] = inst[i].replace("{token}", token)
|
||||
return inst
|
||||
|
|
Loading…
Reference in New Issue