diff --git a/python/src/deltachat/__init__.py b/python/src/deltachat/__init__.py index c8fe3874..0daae841 100644 --- a/python/src/deltachat/__init__.py +++ b/python/src/deltachat/__init__.py @@ -2,7 +2,7 @@ from deltachat import capi, const from deltachat.capi import ffi from deltachat.account import Account # noqa -__version__ = "0.7.1" +__version__ = "0.8.0.dev1" _DC_CALLBACK_MAP = {} diff --git a/python/src/deltachat/message.py b/python/src/deltachat/message.py index 0ecb6452..000d3aa2 100644 --- a/python/src/deltachat/message.py +++ b/python/src/deltachat/message.py @@ -92,13 +92,23 @@ class Message(object): @property_with_doc def time_sent(self): - """time (utc) when the message was sent. + """UTC time when the message was sent. :returns: naive datetime.datetime() object. """ ts = lib.dc_msg_get_timestamp(self._dc_msg) return datetime.utcfromtimestamp(ts) + @property_with_doc + def time_received(self): + """UTC time when the message was received. + + :returns: naive datetime.datetime() object or None if message is an outgoing one. + """ + ts = lib.dc_msg_get_received_timestamp(self._dc_msg) + if ts: + return datetime.utcfromtimestamp(ts) + @property def chat(self): """chat this message was posted in. diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 27d33f78..978e4ef3 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -181,6 +181,7 @@ class TestOfflineAccount: past1s = datetime.utcnow() - timedelta(seconds=1) msg = chat.send_text("msg1") ts = msg.time_sent + assert msg.time_received is None assert ts.strftime("Y") assert past1s < ts contact = msg.get_sender_contact() @@ -259,6 +260,7 @@ class TestOnlineAccount: assert msg_in in chat2.get_messages() assert chat2.is_deaddrop() assert chat2.count_fresh_messages() == 0 + assert msg_in.time_received > msg_in.time_sent lp.sec("create new chat with contact and verify it's proper") chat2b = ac2.create_chat_by_message(msg_in)