summaryrefslogtreecommitdiff
path: root/slixmpp
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-26 00:07:08 +0100
committermathieui <mathieui@mathieui.net>2021-02-26 00:08:56 +0100
commit8e388df8e0d2f6443a0a5deab59ecc355b82532b (patch)
treee42e9731d5cead035fcf5383a0f46f6bb9d3518b /slixmpp
parent8eee559d3983a9fe71837482c6b507ef9b7a0c08 (diff)
downloadslixmpp-8e388df8e0d2f6443a0a5deab59ecc355b82532b.tar.gz
slixmpp-8e388df8e0d2f6443a0a5deab59ecc355b82532b.tar.bz2
slixmpp-8e388df8e0d2f6443a0a5deab59ecc355b82532b.tar.xz
slixmpp-8e388df8e0d2f6443a0a5deab59ecc355b82532b.zip
XEP-0231: do not crash if max-age is None
it is only RECOMMENDED
Diffstat (limited to 'slixmpp')
-rw-r--r--slixmpp/plugins/xep_0231/bob.py3
-rw-r--r--slixmpp/plugins/xep_0231/stanza.py8
2 files changed, 8 insertions, 3 deletions
diff --git a/slixmpp/plugins/xep_0231/bob.py b/slixmpp/plugins/xep_0231/bob.py
index 129aca56..30722208 100644
--- a/slixmpp/plugins/xep_0231/bob.py
+++ b/slixmpp/plugins/xep_0231/bob.py
@@ -89,7 +89,8 @@ class XEP_0231(BasePlugin):
bob['data'] = data
bob['type'] = mtype
bob['cid'] = cid
- bob['max_age'] = max_age
+ if max_age is not None:
+ bob['max_age'] = max_age
await self.api['set_bob'](args=bob)
# Schedule destruction of the data
diff --git a/slixmpp/plugins/xep_0231/stanza.py b/slixmpp/plugins/xep_0231/stanza.py
index 809253d4..6bde671b 100644
--- a/slixmpp/plugins/xep_0231/stanza.py
+++ b/slixmpp/plugins/xep_0231/stanza.py
@@ -18,10 +18,14 @@ class BitsOfBinary(ElementBase):
interfaces = {'cid', 'max_age', 'type', 'data'}
def get_max_age(self):
- return int(self._get_attr('max-age'))
+ try:
+ return int(self._get_attr('max-age'))
+ except ValueError:
+ return None
def set_max_age(self, value):
- self._set_attr('max-age', str(value))
+ if value is not None:
+ self._set_attr('max-age', str(value))
def get_data(self):
return base64.b64decode(bytes(self.xml.text))