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.
This commit is contained in:
parent
88174c2100
commit
e54d37fbc3
1 changed files with 14 additions and 8 deletions
|
|
@ -17,17 +17,17 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
log = getLogger(__name__)
|
||||
from twisted.words.protocols.jabber import jid, xmlstream, client, error as jabber_error
|
||||
from twisted.internet import defer, reactor
|
||||
from sat.core.xmpp import SatXMPPEntity
|
||||
from sat.tools import xml_tools
|
||||
|
||||
from wokkel import data_form
|
||||
log = getLogger(__name__)
|
||||
|
||||
NS_REG = "jabber:iq:register"
|
||||
|
||||
|
|
@ -281,15 +281,21 @@ class XEP_0077(object):
|
|||
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue