Mercurial > libervia-backend
diff src/plugins/plugin_misc_account.py @ 1892:8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 07 Mar 2016 16:20:41 +0100 |
parents | d7e29a12ec2c |
children | e15c7d71ae76 |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_account.py Mon Mar 07 15:48:11 2016 +0100 +++ b/src/plugins/plugin_misc_account.py Mon Mar 07 16:20:41 2016 +0100 @@ -147,6 +147,7 @@ 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 @@ 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 @@ email_auth = C.bool(self.getConfig("email_auth")) domain = self.getConfig('new_account_domain') - # admin + # email to the administrator 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 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"))