plugin misc account: specify domain in new account email sent to admins

This commit is contained in:
Goffi 2021-04-21 11:36:26 +02:00
commit 3377136c62

View file

@ -1,7 +1,6 @@
#!/usr/bin/env python3
# SAT plugin for account creation (experimental)
# Libervia plugin for account creation
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
# This program is free software: you can redistribute it and/or modify
@ -48,14 +47,14 @@ PLUGIN_INFO = {
C.PI_RECOMMENDATIONS: ["GROUPBLOG"],
C.PI_MAIN: "MiscAccount",
C.PI_HANDLER: "no",
C.PI_DESCRIPTION: _("""SàT account creation"""),
C.PI_DESCRIPTION: _("""Libervia account creation"""),
}
CONFIG_SECTION = "plugin account"
# You need do adapt the following consts to your server
# all theses values (key=option name, value=default) can (and should) be overriden in sat.conf
# in section CONFIG_SECTION
# all theses values (key=option name, value=default) can (and should) be overriden
# in libervia.conf in section CONFIG_SECTION
default_conf = {
"email_from": "NOREPLY@example.net",
@ -306,16 +305,14 @@ class MiscAccount(object):
admins_emails = self.getConfig("email_admins_list")
if not admins_emails:
log.warning(
"No known admin email, we can't send email to administrator(s).\nPlease fill email_admins_list parameter"
"No known admin email, we can't send email to administrator(s).\n"
"Please fill email_admins_list parameter"
)
d_admin = defer.fail(exceptions.DataError("no admin email"))
else:
subject = _("New Libervia account created")
body = """New account created: {profile} [{email}]""".format(
profile=profile,
# there is no email when an existing XMPP account is used
email=email or "<no email>",
)
# there is no email when an existing XMPP account is used
body = f"New account created on {domain}: {profile} [{email or '<no email>'}]"
d_admin = sat_email.sendEmail(
self.host.memory.config, admins_emails, subject, body)