XEP-0231: do not crash if max-age is None
it is only RECOMMENDED
This commit is contained in:
parent
8eee559d39
commit
8e388df8e0
2 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue