plugin misc_account: fixes handling of deprecater parameter "admin_email"
This commit is contained in:
parent
ed2219df8f
commit
a6f9cd5bfb
1 changed files with 22 additions and 7 deletions
|
|
@ -147,6 +147,7 @@ class MiscAccount(object):
|
|||
self._prosody_path = dirname(paths[0])
|
||||
log.info(_(u'Prosody path found: %s') % (self._prosody_path,))
|
||||
|
||||
self.fixEmailAdmins()
|
||||
self._sessions = Sessions()
|
||||
|
||||
self.__account_cb_id = host.registerCallback(self._accountDialogCb, with_data=True)
|
||||
|
|
@ -161,6 +162,26 @@ class MiscAccount(object):
|
|||
|
||||
self.__delete_account_id = host.registerCallback(self.__deleteAccountCb, with_data=True)
|
||||
|
||||
|
||||
# FIXME: remove this after some time, when the deprecated parameter is really abandoned
|
||||
def fixEmailAdmins(self):
|
||||
"""Handle deprecated config option "admin_email" to fix the admin emails list"""
|
||||
admin_email = self.getConfig('admin_email')
|
||||
if not admin_email:
|
||||
return
|
||||
log.warning(u"admin_email parameter is deprecated, please use email_admins_list instead")
|
||||
param_name = "email_admins_list"
|
||||
try:
|
||||
section = ""
|
||||
value = self.host.memory.getConfig(section, param_name, Exception)
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
|
||||
section = CONFIG_SECTION
|
||||
value = self.host.memory.getConfig(section, param_name, default_conf[param_name])
|
||||
|
||||
value = set(value)
|
||||
value.add(admin_email)
|
||||
self.host.memory.config.set(section, param_name, ",".join(value))
|
||||
|
||||
def getConfig(self, name):
|
||||
if name.startswith("email_"):
|
||||
# XXX: email_ parameters were first in [plugin account] section
|
||||
|
|
@ -258,14 +279,8 @@ class MiscAccount(object):
|
|||
email_auth = C.bool(self.getConfig("email_auth"))
|
||||
domain = self.getConfig('new_account_domain')
|
||||
|
||||
# admin
|
||||
admins_emails = self.getConfig('email_admins_list')
|
||||
admin_email = self.getConfig('admin_email')
|
||||
if admin_email:
|
||||
log.warning(u"admin_email parameter is deprecated, please use email_admins_list instead")
|
||||
admins_emails.append(admin_email)
|
||||
|
||||
# email to the administrator
|
||||
admins_emails = self.getConfig('email_admins_list')
|
||||
if not admins_emails:
|
||||
log.warning(u"No known admin email, we can't send email to administrator(s).\nPlease fill email_admins_list parameter")
|
||||
d_admin = defer.fail(exceptions.DataError("no admin email"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue