XEP-0313: Do not try to parse date for fields without value.

Without this we end up passing "None"
instead of a str to the date parser,
which raises a TypeError.
It happens if you try to provide a form
to be filled, when slixmpp acts as a MAM
*server*.
This commit is contained in:
nicoco 2024-02-08 20:51:19 +01:00
parent 586d2f5107
commit 909c865524

View File

@ -82,7 +82,7 @@ class MAM(ElementBase):
def get_start(self) -> Optional[datetime]:
fields = self.get_fields()
field = fields.get('start')
if field:
if field and field["value"]:
return xep_0082.parse(field['value'])
return None
@ -95,7 +95,7 @@ class MAM(ElementBase):
def get_end(self) -> Optional[datetime]:
fields = self.get_fields()
field = fields.get('end')
if field:
if field and field["value"]:
return xep_0082.parse(field['value'])
return None