Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1891:b91c8637c656 | 1892:8a5b178ff28b |
---|---|
145 log.error(_(u"Can't find %s") % (self.getConfig('prosodyctl'),)) | 145 log.error(_(u"Can't find %s") % (self.getConfig('prosodyctl'),)) |
146 else: | 146 else: |
147 self._prosody_path = dirname(paths[0]) | 147 self._prosody_path = dirname(paths[0]) |
148 log.info(_(u'Prosody path found: %s') % (self._prosody_path,)) | 148 log.info(_(u'Prosody path found: %s') % (self._prosody_path,)) |
149 | 149 |
150 self.fixEmailAdmins() | |
150 self._sessions = Sessions() | 151 self._sessions = Sessions() |
151 | 152 |
152 self.__account_cb_id = host.registerCallback(self._accountDialogCb, with_data=True) | 153 self.__account_cb_id = host.registerCallback(self._accountDialogCb, with_data=True) |
153 self.__change_password_id = host.registerCallback(self.__changePasswordCb, with_data=True) | 154 self.__change_password_id = host.registerCallback(self.__changePasswordCb, with_data=True) |
154 | 155 |
158 self.__delete_posts_id = host.registerCallback(deleteBlogCallback(True, False), with_data=True) | 159 self.__delete_posts_id = host.registerCallback(deleteBlogCallback(True, False), with_data=True) |
159 self.__delete_comments_id = host.registerCallback(deleteBlogCallback(False, True), with_data=True) | 160 self.__delete_comments_id = host.registerCallback(deleteBlogCallback(False, True), with_data=True) |
160 self.__delete_posts_comments_id = host.registerCallback(deleteBlogCallback(True, True), with_data=True) | 161 self.__delete_posts_comments_id = host.registerCallback(deleteBlogCallback(True, True), with_data=True) |
161 | 162 |
162 self.__delete_account_id = host.registerCallback(self.__deleteAccountCb, with_data=True) | 163 self.__delete_account_id = host.registerCallback(self.__deleteAccountCb, with_data=True) |
164 | |
165 | |
166 # FIXME: remove this after some time, when the deprecated parameter is really abandoned | |
167 def fixEmailAdmins(self): | |
168 """Handle deprecated config option "admin_email" to fix the admin emails list""" | |
169 admin_email = self.getConfig('admin_email') | |
170 if not admin_email: | |
171 return | |
172 log.warning(u"admin_email parameter is deprecated, please use email_admins_list instead") | |
173 param_name = "email_admins_list" | |
174 try: | |
175 section = "" | |
176 value = self.host.memory.getConfig(section, param_name, Exception) | |
177 except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): | |
178 section = CONFIG_SECTION | |
179 value = self.host.memory.getConfig(section, param_name, default_conf[param_name]) | |
180 | |
181 value = set(value) | |
182 value.add(admin_email) | |
183 self.host.memory.config.set(section, param_name, ",".join(value)) | |
163 | 184 |
164 def getConfig(self, name): | 185 def getConfig(self, name): |
165 if name.startswith("email_"): | 186 if name.startswith("email_"): |
166 # XXX: email_ parameters were first in [plugin account] section | 187 # XXX: email_ parameters were first in [plugin account] section |
167 # but as it make more sense to have them in common with other plugins, | 188 # but as it make more sense to have them in common with other plugins, |
256 email_password = self.getConfig("email_password") or None | 277 email_password = self.getConfig("email_password") or None |
257 email_starttls = C.bool(self.getConfig("email_starttls")) | 278 email_starttls = C.bool(self.getConfig("email_starttls")) |
258 email_auth = C.bool(self.getConfig("email_auth")) | 279 email_auth = C.bool(self.getConfig("email_auth")) |
259 domain = self.getConfig('new_account_domain') | 280 domain = self.getConfig('new_account_domain') |
260 | 281 |
261 # admin | 282 # email to the administrator |
262 admins_emails = self.getConfig('email_admins_list') | 283 admins_emails = self.getConfig('email_admins_list') |
263 admin_email = self.getConfig('admin_email') | |
264 if admin_email: | |
265 log.warning(u"admin_email parameter is deprecated, please use email_admins_list instead") | |
266 admins_emails.append(admin_email) | |
267 | |
268 # email to the administrator | |
269 if not admins_emails: | 284 if not admins_emails: |
270 log.warning(u"No known admin email, we can't send email to administrator(s).\nPlease fill email_admins_list parameter") | 285 log.warning(u"No known admin email, we can't send email to administrator(s).\nPlease fill email_admins_list parameter") |
271 d_admin = defer.fail(exceptions.DataError("no admin email")) | 286 d_admin = defer.fail(exceptions.DataError("no admin email")) |
272 else: | 287 else: |
273 body = (u"""New account created: %(profile)s [%(email)s]""" % {'profile': profile, 'email': email}).encode('utf-8') | 288 body = (u"""New account created: %(profile)s [%(email)s]""" % {'profile': profile, 'email': email}).encode('utf-8') |