changeset 1916:72837638f076

plugin misc_account: fixes two bugs introduced by revision 1907 (0b748ad46ede): - the email sent to the user was not displaying its his/her JID - creating an account from an external JID was not returning a bool
author souliane <souliane@mailoo.org>
date Mon, 21 Mar 2016 17:00:39 +0100
parents fd959c8f64b6
children 05a5a125a238
files src/plugins/plugin_misc_account.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_misc_account.py	Fri Mar 18 10:25:38 2016 +0100
+++ b/src/plugins/plugin_misc_account.py	Mon Mar 21 17:00:39 2016 +0100
@@ -222,7 +222,7 @@
         @return Deferred
         """
         d = self.createProfile(password, jid_s, profile)
-        d.addCallback(lambda dummy: self.sendEmails(email, jid_s, password, profile))
+        d.addCallback(lambda dummy: self.sendEmails(email, profile))
         return d
 
     def createProfile(self, password, jid_s, profile):
@@ -278,7 +278,7 @@
         d.addErrback(removeProfile)
         return d
 
-    def sendEmails(self, email, jid_s, password, profile):
+    def sendEmails(self, email, profile):
         # time to send the email
 
         email_host = self.getConfig('email_server')
@@ -322,6 +322,7 @@
         if not email:
             return d_admin
 
+        jid_s = self.host.memory.getParamA("JabberID", "Connection", profile_key=profile)
         body = (_(u"""Welcome to Libervia, the web interface of Salut à Toi.
 
 Your account on {domain} has been successfully created. This is a demonstration version to show you the current status of the project. It is still under development, please keep it in mind!
@@ -618,6 +619,11 @@
         d.addCallback(lambda dummy: self.host.memory.getProfileName(jid_s))  # checks if the profile has been successfuly created
         d.addCallback(self.host.asyncConnect, password, 0)
 
+
+        def connected(result):
+            self.sendEmails(None, profile=jid_s)
+            return result
+
         def removeProfile(failure):  # profile has been successfully created but the XMPP credentials are wrong!
             log.debug("Removing previously auto-created profile: %s" % failure.getErrorMessage())
             self.host.memory.asyncDeleteProfile(jid_s)
@@ -626,5 +632,5 @@
         # FIXME: we don't catch the case where the JID host is not an XMPP server, and the user
         # has to wait until the DBUS timeout ; as a consequence, emails are sent to the admins
         # and the profile is not deleted. When the host exists, removeProfile is well called.
-        d.addCallbacks(lambda dummy: self.sendEmails(None, jid_s, password, jid_s), removeProfile)
+        d.addCallbacks(connected, removeProfile)
         return d