Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_email_invitation.py @ 3040:fee60f17ebac
jp: jp asyncio port:
/!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\
This patch implements the port of jp to asyncio, so it is now correctly using the bridge
asynchronously, and it can be used with bridges like `pb`. This also simplify the code,
notably for things which were previously implemented with many callbacks (like pagination
with RSM).
During the process, some behaviours have been modified/fixed, in jp and backends, check
diff for details.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 25 Sep 2019 08:56:41 +0200 |
parents | ab2696e34d29 |
children | 0c29155ac68b |
comparison
equal
deleted
inserted
replaced
3039:a1bc34f90fa5 | 3040:fee60f17ebac |
---|---|
252 log.info(_("requested jid already exists, trying with {}".format( | 252 log.info(_("requested jid already exists, trying with {}".format( |
253 jid_.full()))) | 253 jid_.full()))) |
254 try: | 254 try: |
255 yield self.host.plugins['XEP-0077'].registerNewAccount(jid_, | 255 yield self.host.plugins['XEP-0077'].registerNewAccount(jid_, |
256 password) | 256 password) |
257 except error.StanzaError as e: | 257 except error.StanzaError: |
258 idx += 1 | 258 idx += 1 |
259 else: | 259 else: |
260 break | 260 break |
261 if e.condition != 'conflict': | 261 if e.condition != 'conflict': |
262 raise e | 262 raise e |
319 | 319 |
320 invite_url = url_template.format(**format_args) | 320 invite_url = url_template.format(**format_args) |
321 format_args['url'] = invite_url | 321 format_args['url'] = invite_url |
322 | 322 |
323 yield sat_email.sendEmail( | 323 yield sat_email.sendEmail( |
324 self.host, | 324 self.host.memory.config, |
325 [email] + emails_extra, | 325 [email] + emails_extra, |
326 (kwargs.pop('message_subject', None) or DEFAULT_SUBJECT).format( | 326 (kwargs.pop('message_subject', None) or DEFAULT_SUBJECT).format( |
327 **format_args), | 327 **format_args), |
328 (kwargs.pop('message_body', None) or DEFAULT_BODY).format(**format_args), | 328 (kwargs.pop('message_body', None) or DEFAULT_BODY).format(**format_args), |
329 ) | 329 ) |
399 | 399 |
400 @param profile(unicode): return invitation linked to this profile only | 400 @param profile(unicode): return invitation linked to this profile only |
401 C.PROF_KEY_NONE: don't filter invitations | 401 C.PROF_KEY_NONE: don't filter invitations |
402 @return list(unicode): invitations uids | 402 @return list(unicode): invitations uids |
403 """ | 403 """ |
404 invitations = yield list(self.invitations.items()) | 404 invitations = yield self.invitations.items() |
405 if profile != C.PROF_KEY_NONE: | 405 if profile != C.PROF_KEY_NONE: |
406 invitations = {id_:data for id_, data in invitations.items() | 406 invitations = {id_:data for id_, data in invitations.items() |
407 if data.get('profile') == profile} | 407 if data.get('profile') == profile} |
408 | 408 |
409 defer.returnValue(invitations) | 409 defer.returnValue(invitations) |