plugin misc_account: send email to the admins when a new profile is created for an external XMPP account
This commit is contained in:
parent
192b5a0275
commit
a8a58cb01a
1 changed files with 15 additions and 11 deletions
|
|
@ -209,8 +209,8 @@ class MiscAccount(object):
|
|||
else:
|
||||
d = ProsodyRegisterProtocol.prosodyctl(self, 'adduser', password, profile)
|
||||
jid_s = "%s@%s" % (profile, self.getConfig('new_account_domain'))
|
||||
if email:
|
||||
d.addCallback(lambda dummy: self.sendEmails(email, jid_s, password, profile))
|
||||
|
||||
d.addCallback(lambda dummy: self.sendEmails(email, jid_s, password, profile))
|
||||
|
||||
def setParams(dummy):
|
||||
self.host.memory.setParam("JabberID", jid_s, "Connection", profile_key=profile)
|
||||
|
|
@ -242,6 +242,19 @@ class MiscAccount(object):
|
|||
# TODO: return error code to user
|
||||
log.error(u"Failed to send email to %s" % email)
|
||||
|
||||
# email to the administrator
|
||||
body = (u"""New account created: %(profile)s [%(email)s]""" % {'profile': profile, 'email': email}).encode('utf-8')
|
||||
msg = MIMEText(body, 'plain', 'UTF-8')
|
||||
msg['Subject'] = _('New Libervia account created')
|
||||
msg['From'] = _email_from
|
||||
msg['To'] = self.getConfig('admin_email')
|
||||
|
||||
d_admin = sendmail(_email_host, _email_from, self.getConfig('admin_email'), msg.as_string())
|
||||
d_admin.addCallbacks(email_ok, email_ko)
|
||||
|
||||
if not email:
|
||||
return d_admin
|
||||
|
||||
body = (_(u"""Welcome to Libervia, the web interface of Salut à Toi.
|
||||
|
||||
Your account on %(domain)s has been successfully created. This is a demonstration version to show you the current status of the project. It is still under development, it misses some features and it's not stable enough to be used for any serious purpose. Please keep it in mind!
|
||||
|
|
@ -272,15 +285,6 @@ http://www.salut-a-toi.org
|
|||
d_user = sendmail(_email_host, _email_from, email, msg.as_string())
|
||||
d_user.addCallbacks(email_ok, email_ko)
|
||||
|
||||
# email to the administrator
|
||||
body = (u"""New account created: %(profile)s [%(email)s]""" % {'profile': profile, 'email': email}).encode('utf-8')
|
||||
msg = MIMEText(body, 'plain', 'UTF-8')
|
||||
msg['Subject'] = _('New Libervia account created')
|
||||
msg['From'] = _email_from
|
||||
msg['To'] = self.getConfig('admin_email')
|
||||
|
||||
d_admin = sendmail(_email_host, _email_from, self.getConfig('admin_email'), msg.as_string())
|
||||
d_admin.addCallbacks(email_ok, email_ko)
|
||||
return defer.DeferredList([d_user, d_admin])
|
||||
|
||||
def getNewAccountDomain(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue