mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 10:19:16 +02:00
add msg.time_received and a test
This commit is contained in:
parent
fb334b8b05
commit
ad84e4578b
3 changed files with 14 additions and 2 deletions
|
@ -2,7 +2,7 @@ from deltachat import capi, const
|
||||||
from deltachat.capi import ffi
|
from deltachat.capi import ffi
|
||||||
from deltachat.account import Account # noqa
|
from deltachat.account import Account # noqa
|
||||||
|
|
||||||
__version__ = "0.7.1"
|
__version__ = "0.8.0.dev1"
|
||||||
|
|
||||||
|
|
||||||
_DC_CALLBACK_MAP = {}
|
_DC_CALLBACK_MAP = {}
|
||||||
|
|
|
@ -92,13 +92,23 @@ class Message(object):
|
||||||
|
|
||||||
@property_with_doc
|
@property_with_doc
|
||||||
def time_sent(self):
|
def time_sent(self):
|
||||||
"""time (utc) when the message was sent.
|
"""UTC time when the message was sent.
|
||||||
|
|
||||||
:returns: naive datetime.datetime() object.
|
:returns: naive datetime.datetime() object.
|
||||||
"""
|
"""
|
||||||
ts = lib.dc_msg_get_timestamp(self._dc_msg)
|
ts = lib.dc_msg_get_timestamp(self._dc_msg)
|
||||||
return datetime.utcfromtimestamp(ts)
|
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
|
@property
|
||||||
def chat(self):
|
def chat(self):
|
||||||
"""chat this message was posted in.
|
"""chat this message was posted in.
|
||||||
|
|
|
@ -181,6 +181,7 @@ class TestOfflineAccount:
|
||||||
past1s = datetime.utcnow() - timedelta(seconds=1)
|
past1s = datetime.utcnow() - timedelta(seconds=1)
|
||||||
msg = chat.send_text("msg1")
|
msg = chat.send_text("msg1")
|
||||||
ts = msg.time_sent
|
ts = msg.time_sent
|
||||||
|
assert msg.time_received is None
|
||||||
assert ts.strftime("Y")
|
assert ts.strftime("Y")
|
||||||
assert past1s < ts
|
assert past1s < ts
|
||||||
contact = msg.get_sender_contact()
|
contact = msg.get_sender_contact()
|
||||||
|
@ -259,6 +260,7 @@ class TestOnlineAccount:
|
||||||
assert msg_in in chat2.get_messages()
|
assert msg_in in chat2.get_messages()
|
||||||
assert chat2.is_deaddrop()
|
assert chat2.is_deaddrop()
|
||||||
assert chat2.count_fresh_messages() == 0
|
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")
|
lp.sec("create new chat with contact and verify it's proper")
|
||||||
chat2b = ac2.create_chat_by_message(msg_in)
|
chat2b = ac2.create_chat_by_message(msg_in)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue