From 0f2fa095283bd467ecfc54877fc27f7cefb65db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sat, 21 Dec 2019 10:55:51 +0100 Subject: Add HTTP Upload (XEP-0363) support --- nbxmpp/structs.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'nbxmpp/structs.py') diff --git a/nbxmpp/structs.py b/nbxmpp/structs.py index 347d4b1..252ef3f 100644 --- a/nbxmpp/structs.py +++ b/nbxmpp/structs.py @@ -136,6 +136,10 @@ RegisterData = namedtuple('RegisterData', 'instructions form fields_form oob_url ChangePasswordResult = namedtuple('ChangePasswordResult', 'successful form') ChangePasswordResult.__new__.__defaults__ = (None,) +HTTPUploadData = namedtuple('HTTPUploadData', 'put_uri get_uri headers') +HTTPUploadData.__new__.__defaults__ = (None,) + + class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms timestamp')): __slots__ = [] @@ -449,6 +453,25 @@ class CommonError: payload=self._error_node)) +class HTTPUploadError(CommonError): + def __init__(self, stanza): + CommonError.__init__(self, stanza) + + def get_max_file_size(self): + if not self.app_condition == 'file-too-large': + return None + node = self._error_node.getTag(self.app_condition) + try: + return float(node.getTagData('max-file-size')) + except Exception: + return None + + def get_retry_date(self): + if not self.app_condition == 'retry': + return None + return self._error_node.getTagAttr('stamp') + + class StanzaMalformedError(CommonError): def __init__(self, stanza, text): self._error_node = None -- cgit v1.2.3