Support old and deprecated XEP 0091 because it's still used on buggy servers...

Support old and deprecated XEP 0091 because it's still used on buggy servers like @conference.codingteam.net. Fixed #1677
parent 32925f51
......@@ -264,7 +264,10 @@ def datetime_tuple(timestamp):
"""
timestamp = timestamp.split('.')[0]
timestamp = timestamp.replace('-', '')
ret = datetime.strptime(timestamp, '%Y%m%dT%H:%M:%SZ')
try:
ret = datetime.strptime(timestamp, '%Y%m%dT%H:%M:%SZ')
except ValueError: # Support the deprecated format, XEP 0091 :(
ret = datetime.strptime(timestamp, '%Y%m%dT%H:%M:%S')
# convert UTC to local time, with DST etc.
dst = timedelta(seconds=time.altzone)
ret -= dst
......
......@@ -387,7 +387,14 @@ class Gui(object):
delayed = True
date = common.datetime_tuple(delay_tag.getAttr('stamp'))
else:
delayed = False
# We support the OLD and deprecated XEP: http://xmpp.org/extensions/xep-0091.html
# But it sucks, please, Jabber servers, don't do this :(
delay_tag = stanza.getTag('x', namespace='jabber:x:delay')
if delay_tag:
delayed = True
date = common.datetime_tuple(delay_tag.getAttr('stamp'))
else:
delayed = False
if stanza.getType() != 'groupchat':
return # ignore all messages not comming from a MUC
nick_from = stanza.getFrom().getResource()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment