Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2022-09-27 00:12:27 +0300
committerwurstsalat <mailtrash@posteo.de>2022-09-27 00:12:27 +0300
commit86690d0b3f46001dd1ddcbd28414bc9810e221a2 (patch)
treee554052af206f002210c2c8d292f6819c18d95c9
parent8474c016624fbe9086c3cb78b1a93d9b4baa63a9 (diff)
cfix: AddContact: Add missing discovery timeout
-rw-r--r--gajim/gtk/add_contact.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/gajim/gtk/add_contact.py b/gajim/gtk/add_contact.py
index 470bf64cd..5fd95a3cc 100644
--- a/gajim/gtk/add_contact.py
+++ b/gajim/gtk/add_contact.py
@@ -26,6 +26,7 @@ from gi.repository import Gtk
from nbxmpp import JID
from nbxmpp import Namespace
from nbxmpp.errors import is_error
+from nbxmpp.errors import BaseError
from nbxmpp.errors import StanzaError
from nbxmpp.structs import DiscoInfo
@@ -145,9 +146,11 @@ class AddContact(Assistant):
client = app.get_client(account)
- result = yield client.get_module('Discovery').disco_info(address)
+ result = yield client.get_module('Discovery').disco_info(
+ address,
+ timeout=10)
if is_error(result):
- assert isinstance(result, StanzaError)
+ assert isinstance(result, BaseError)
self._process_error(account, result)
raise result
@@ -155,7 +158,11 @@ class AddContact(Assistant):
assert isinstance(result, DiscoInfo)
self._process_info(account, result)
- def _process_error(self, account: str, result: StanzaError) -> None:
+ def _process_error(self,
+ account: str,
+ result: BaseError
+ ) -> None:
+
log.debug('Error received: %s', result)
self._result = result
@@ -163,12 +170,14 @@ class AddContact(Assistant):
'service-unavailable', # Prosody
'subscription-required' # ejabberd
]
- if result.condition in contact_conditions:
+ if (isinstance(self._result, StanzaError) and
+ result.condition in contact_conditions):
# It seems to be a contact
address_page = cast(Contact, self.get_page('contact'))
address_page.prepare(account, result)
self.show_page('contact', Gtk.StackTransitionType.SLIDE_LEFT)
else:
+ # TimeoutStanzaError is handled here
error_page = cast(ErrorPage, self.get_page('error'))
error_page.set_text(result.get_text())
self.show_page('error', Gtk.StackTransitionType.SLIDE_LEFT)
@@ -342,7 +351,7 @@ class Contact(Page):
Page.__init__(self)
self.title = _('Add Contact')
- self._result: Union[DiscoInfo, StanzaError, None] = None
+ self._result: Union[DiscoInfo, BaseError, None] = None
self._account: Optional[str] = None
self._contact: Optional[types.BareContact] = None