Commit 70cbf4b4 authored by Tijmen de Mes's avatar Tijmen de Mes

Fixed timestamps in incoming messages

parent 210006d5
...@@ -337,8 +337,8 @@ class MessageHistory(object, metaclass=Singleton): ...@@ -337,8 +337,8 @@ class MessageHistory(object, metaclass=Singleton):
timestamp_native = message.timestamp timestamp_native = message.timestamp
timestamp_utc = timestamp_native.replace(tzinfo=timezone.utc) timestamp_utc = timestamp_native.replace(tzinfo=timezone.utc)
message.timestamp = timestamp_utc - message.timestamp.utcoffset() timestamp_fixed = timestamp_utc - message.timestamp.utcoffset()
timestamp = parse(str(message.timestamp)) timestamp = parse(str(timestamp_fixed))
optional_fields = {} optional_fields = {}
if state is not None: if state is not None:
...@@ -396,8 +396,8 @@ class MessageHistory(object, metaclass=Singleton): ...@@ -396,8 +396,8 @@ class MessageHistory(object, metaclass=Singleton):
timestamp_native = message.timestamp timestamp_native = message.timestamp
timestamp_utc = timestamp_native.replace(tzinfo=timezone.utc) timestamp_utc = timestamp_native.replace(tzinfo=timezone.utc)
message.timestamp = timestamp_utc - message.timestamp.utcoffset() timestamp_fixed = timestamp_utc - message.timestamp.utcoffset()
timestamp = parse(str(message.timestamp)) timestamp = parse(str(timestamp_fixed))
optional_fields = {} optional_fields = {}
if state is not None: if state is not None:
......
...@@ -21,7 +21,7 @@ from application.python import Null ...@@ -21,7 +21,7 @@ from application.python import Null
from application.system import makedirs from application.system import makedirs
from application.python.types import Singleton from application.python.types import Singleton
from datetime import timezone from datetime import timezone
from dateutil.tz import tzlocal from dateutil.tz import tzlocal, tzutc
from urllib.parse import urlsplit, urlunsplit, quote from urllib.parse import urlsplit, urlunsplit, quote
from zope.interface import implementer from zope.interface import implementer
...@@ -947,7 +947,10 @@ class MessageManager(object, metaclass=Singleton): ...@@ -947,7 +947,10 @@ class MessageManager(object, metaclass=Singleton):
session_manager = SessionManager() session_manager = SessionManager()
notification_center = NotificationCenter() notification_center = NotificationCenter()
timestamp = str(cpim_message.timestamp) if cpim_message is not None and cpim_message.timestamp is not None else str(ISOTimestamp.now()) timestamp = cpim_message.timestamp if cpim_message is not None and cpim_message.timestamp is not None else ISOTimestamp.now()
if timestamp.tzinfo is tzutc():
timestamp = timestamp.replace(tzinfo=timezone.utc).astimezone(tzlocal())
timestamp = str(timestamp)
message = BlinkMessage(body, content_type, sender, timestamp=timestamp, id=message_id, disposition=disposition, direction='incoming') message = BlinkMessage(body, content_type, sender, timestamp=timestamp, id=message_id, disposition=disposition, direction='incoming')
if x_replicated_message is not Null: if x_replicated_message is not Null:
......
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