diff src/plugins/plugin_misc_account.py @ 934:34dd9287dfe5

plugin account: bug fix profile deletion from the database + unsubscribe the contacts
author souliane <souliane@mailoo.org>
date Mon, 24 Mar 2014 16:21:14 +0100
parents 52ee240acc9c
children fc7e0828b18e
line wrap: on
line diff
--- a/src/plugins/plugin_misc_account.py	Mon Mar 24 10:16:07 2014 +0100
+++ b/src/plugins/plugin_misc_account.py	Mon Mar 24 16:21:14 2014 +0100
@@ -105,6 +105,7 @@
         d = defer.Deferred()
         prosody_reg = ProsodyRegisterProtocol(password, d)
         prosody_exe = join(plugin._prosody_path, plugin.getConfig('prosodyctl'))
+        # TODO delete account which are not on the same host
         reactor.spawnProcess(prosody_reg, prosody_exe, [prosody_exe, command, "%s@%s" % (profile, plugin.getConfig('new_account_domain'))], path=plugin._prosody_path)
         return d
 
@@ -318,6 +319,14 @@
         @param profile
         """
         def userDeleted(result):
+            client = self.host.profiles[profile]
+
+            for jid_ in client.roster._jids:  # empty roster
+                client.presence.unsubscribe(jid_)
+
+            for jid_ in self.host.memory.getWaitingSub(profile):  # delete waiting subscriptions
+                self.host.memory.delWaitingSub(jid_)
+
             self.host.disconnect(profile)
             self.host.memory.asyncDeleteProfile(profile, force=True)
             return defer.succeed({})