Fix provisioning with emails

master
Mark Veidemanis 2 years ago
parent 745c7caa12
commit 5c7d71dc99

@ -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…
Cancel
Save