Commit 2002c3cf authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Use parse_datetime for parsing idle time

Fixes #9393
parent b9e02f20
......@@ -30,6 +30,7 @@
from gajim.common import i18n
from gajim.common.i18n import _
from gajim.common.modules import dataforms
from gajim.common.modules.misc import parse_idle
from gajim.common.const import KindConstant, SSLError
from gajim.common.pep import SUPPORTED_PERSONAL_USER_EVENTS
from gajim.common.jingle_transport import JingleTransportSocks5
......@@ -254,12 +255,7 @@ def generate(self):
if delay_tag:
# XEP-0319
self.idle_time = None
idle_tag = self.stanza.getTag('idle', namespace=nbxmpp.NS_IDLE)
if idle_tag:
time_str = idle_tag.getAttr('since')
tim = helpers.datetime_tuple(time_str)
self.idle_time = timegm(tim)
self.idle_time = parse_idle(self.stanza)
xtags = self.stanza.getTags('x')
for x in xtags:
......@@ -139,3 +139,24 @@ def parse_xhtml(stanza):
if app.config.get('ignore_incoming_xhtml'):
return None
return stanza.getXHTML()
# XEP-0319: Last User Interaction in Presence
def parse_idle(stanza):
idle_tag = stanza.getTag('idle', namespace=nbxmpp.NS_IDLE)
if idle_tag is None:
since = idle_tag.getAttr('since')
if since is None:
log.warning('No since attr in idle node')
timestamp = parse_datetime(since, convert='utc', epoch=True)
if timestamp is None:
log.warning('Invalid timestamp received: %s', since)
return timestamp
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