Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0077.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0077.py Tue Jun 18 12:06:45 2024 +0200 +++ b/libervia/backend/plugins/plugin_xep_0077.py Wed Jun 19 18:44:57 2024 +0200 @@ -48,7 +48,7 @@ # FIXME: request IQ is not send to check available fields, # while XEP recommand to use it # FIXME: doesn't handle data form or oob - namespace = 'jabber:client' + namespace = "jabber:client" def __init__(self, jid_, password, email=None, check_certificate=True): log.debug(_("Registration asked for {jid}").format(jid=jid_)) @@ -70,15 +70,25 @@ tls_required = False configurationForTLS = ssl.CertificateOptions(trustRoot=None) tls_init = xmlstream.TLSInitiatingInitializer( - xs, required=tls_required, configurationForTLS=configurationForTLS) + xs, required=tls_required, configurationForTLS=configurationForTLS + ) xs.initializers.append(tls_init) def register(self, xmlstream): - log.debug(_("Stream started with {server}, now registering" - .format(server=self.jid.host))) - iq = XEP_0077.build_register_iq(self.xmlstream, self.jid, self.password, self.email) - d = iq.send(self.jid.host).addCallbacks(self.registration_cb, self.registration_eb) + log.debug( + _( + "Stream started with {server}, now registering".format( + server=self.jid.host + ) + ) + ) + iq = XEP_0077.build_register_iq( + self.xmlstream, self.jid, self.password, self.email + ) + d = iq.send(self.jid.host).addCallbacks( + self.registration_cb, self.registration_eb + ) d.chainDeferred(self.registered) def registration_cb(self, answer): @@ -261,10 +271,11 @@ @param port(int): port of the server to register to """ if host is None: - host = self.host.memory.config_get("", "xmpp_domain", "127.0.0.1") + host = self.host.memory.config_get("", "xmpp_domain", "127.0.0.1") check_certificate = host != "127.0.0.1" authenticator = RegisteringAuthenticator( - jid_, password, email, check_certificate=check_certificate) + jid_, password, email, check_certificate=check_certificate + ) registered_d = authenticator.registered server_register = ServerRegister(authenticator) reactor.connectTCP(host, port, server_register) @@ -288,11 +299,7 @@ client = self.host.get_client(profile_key) return self.unregister(client, jid.JID(to_jid_s)) - def unregister( - self, - client: SatXMPPEntity, - to_jid: jid.JID - ) -> defer.Deferred: + 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 @@ -309,4 +316,3 @@ if not to_jid or to_jid == jid.JID(client.jid.host): d.addCallback(lambda __: client.entity_disconnect()) return d -