diff --git a/python/src/deltachat/chatting.py b/python/src/deltachat/chatting.py index 3ba6ba6ce..84f825147 100644 --- a/python/src/deltachat/chatting.py +++ b/python/src/deltachat/chatting.py @@ -410,7 +410,7 @@ class Chat(object): latitude=lib.dc_array_get_latitude(dc_array, i), longitude=lib.dc_array_get_longitude(dc_array, i), accuracy=lib.dc_array_get_accuracy(dc_array, i), - timestamp=datetime.utcfromtimestamp(lib.dc_array_get_accuracy(dc_array, i)), + timestamp=datetime.utcfromtimestamp(lib.dc_array_get_timestamp(dc_array, i)), )) return locations @@ -422,3 +422,6 @@ class Location: self.longitude = longitude self.accuracy = accuracy self.timestamp = timestamp + + def __eq__(self, other): + return self.__dict__ == other.__dict__ diff --git a/python/tests/test_account.py b/python/tests/test_account.py index ef583d806..d13138d70 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -811,6 +811,7 @@ class TestOnlineAccount: assert chat.get_profile_image() is None def test_send_receive_locations(self, acfactory, lp): + now = datetime.utcnow() ac1, ac2 = acfactory.get_two_online_accounts() lp.sec("ac1: create chat with ac2") @@ -829,7 +830,7 @@ class TestOnlineAccount: assert chat1.is_sending_locations() ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") - ac1.set_location(latitude=2.0, longitude=3.0) + ac1.set_location(latitude=2.0, longitude=3.0, accuracy=0.5) ac1._evlogger.get_matching("DC_EVENT_LOCATION_CHANGED") chat1.send_text("hello") ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") @@ -841,9 +842,21 @@ class TestOnlineAccount: ac2._evlogger.get_matching("DC_EVENT_LOCATION_CHANGED") ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG") # text message with location - # contact = ac2.create_contact(ac1.get_config("addr")) - locations = chat2.get_locations() # XXX per contact + locations = chat2.get_locations() assert len(locations) >= 1 + assert locations[0].latitude == 2.0 + assert locations[0].longitude == 3.0 + assert locations[0].accuracy == 0.5 + assert locations[0].timestamp > now + + contact = ac2.create_contact(ac1.get_config("addr")) + locations2 = chat2.get_locations(contact=contact) + assert len(locations2) >= 1 + assert locations2 == locations + + contact = ac2.create_contact("nonexisting@example.org") + locations3 = chat2.get_locations(contact=contact) + assert not locations3 class TestOnlineConfigureFails: diff --git a/src/dc_mimeparser.rs b/src/dc_mimeparser.rs index d92757390..602a1a6f3 100644 --- a/src/dc_mimeparser.rs +++ b/src/dc_mimeparser.rs @@ -813,9 +813,6 @@ impl<'a> MimeParser<'a> { } fn do_add_single_part(&mut self, mut part: Part) { - // we transfer the encryption-state to each part - // because each part lands to each part ? Autocrypt does not define "partially encrypted" - // so either the whole message is encrypted properly or nothing if self.encrypted { if self.signatures.len() > 0 { part.param.set_int(Param::GuaranteeE2ee, 1);