# HG changeset patch # User Goffi # Date 1597355178 -7200 # Node ID 2cd54c72fae40924862549a4b12e2807d4e50f0b # Parent ac9342f359e9b176130c00bb38c942c1193855c4 plugin XEP-0077: None can now be used in `to_jid` argument in `unregister`: if None is used, the XMPP account of the profile will be deleted. diff -r ac9342f359e9 -r 2cd54c72fae4 sat/plugins/plugin_xep_0077.py --- a/sat/plugins/plugin_xep_0077.py Thu Aug 13 23:46:18 2020 +0200 +++ b/sat/plugins/plugin_xep_0077.py Thu Aug 13 23:46:18 2020 +0200 @@ -17,17 +17,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from twisted.words.protocols.jabber import jid, xmlstream, client, error as jabber_error +from twisted.internet import defer, reactor +from wokkel import data_form from sat.core.i18n import _ from sat.core.constants import Const as C from sat.core import exceptions from sat.core.log import getLogger +from sat.core.xmpp import SatXMPPEntity +from sat.tools import xml_tools log = getLogger(__name__) -from twisted.words.protocols.jabber import jid, xmlstream, client, error as jabber_error -from twisted.internet import defer, reactor -from sat.tools import xml_tools - -from wokkel import data_form NS_REG = "jabber:iq:register" @@ -281,15 +281,21 @@ client = self.host.getClient(profile_key) return self.unregister(client, jid.JID(to_jid_s)) - def unregister(self, client, to_jid): + def unregister( + self, + client: SatXMPPEntity, + to_jid: jid.JID + ) -> defer.Deferred: """remove registration from a server/service BEWARE! if you remove registration from profile own server, this will DELETE THE XMPP ACCOUNT WITHOUT WARNING - @param to_jid(jid.JID): jid of the service or server + @param to_jid: jid of the service or server + None to delete client's account (DANGEROUS!) """ iq_elt = client.IQ() - iq_elt["to"] = to_jid.full() + if to_jid is not None: + iq_elt["to"] = to_jid.full() query_elt = iq_elt.addElement((NS_REG, "query")) query_elt.addElement("remove") return iq_elt.send()