mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
fix(python): Use cached message object if dc_get_msg() returns NULL
Particularly, in _msgstate() and download_state(). If the message has been trashed, dc_get_msg() returns NULL now.
This commit is contained in:
@@ -364,6 +364,9 @@ class Message:
|
|||||||
else:
|
else:
|
||||||
# load message from db to get a fresh/current state
|
# load message from db to get a fresh/current state
|
||||||
dc_msg = ffi.gc(lib.dc_get_msg(self.account._dc_context, self.id), lib.dc_msg_unref)
|
dc_msg = ffi.gc(lib.dc_get_msg(self.account._dc_context, self.id), lib.dc_msg_unref)
|
||||||
|
# Message could be trashed, use the cached object if so.
|
||||||
|
if dc_msg == ffi.NULL:
|
||||||
|
dc_msg = self._dc_msg
|
||||||
return lib.dc_msg_get_state(dc_msg)
|
return lib.dc_msg_get_state(dc_msg)
|
||||||
|
|
||||||
def is_in_fresh(self):
|
def is_in_fresh(self):
|
||||||
@@ -484,6 +487,9 @@ class Message:
|
|||||||
|
|
||||||
# load message from db to get a fresh/current state
|
# load message from db to get a fresh/current state
|
||||||
dc_msg = ffi.gc(lib.dc_get_msg(self.account._dc_context, self.id), lib.dc_msg_unref)
|
dc_msg = ffi.gc(lib.dc_get_msg(self.account._dc_context, self.id), lib.dc_msg_unref)
|
||||||
|
# Message could be trashed, use the cached object if so.
|
||||||
|
if dc_msg == ffi.NULL:
|
||||||
|
dc_msg = self._dc_msg
|
||||||
return lib.dc_msg_get_download_state(dc_msg)
|
return lib.dc_msg_get_download_state(dc_msg)
|
||||||
|
|
||||||
def download_full(self) -> None:
|
def download_full(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user