mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
fix Chat.prepare_message()
This commit is contained in:
@@ -254,17 +254,19 @@ class Chat(object):
|
|||||||
return Message.from_db(self.account, sent_id)
|
return Message.from_db(self.account, sent_id)
|
||||||
|
|
||||||
def prepare_message(self, msg):
|
def prepare_message(self, msg):
|
||||||
""" create a new prepared message.
|
""" prepare a message for sending.
|
||||||
|
|
||||||
:param msg: the message to be prepared.
|
:param msg: the message to be prepared.
|
||||||
:returns: :class:`deltachat.message.Message` instance.
|
:returns: a :class:`deltachat.message.Message` instance.
|
||||||
|
This is the same object that was passed in, which
|
||||||
|
has been modified with the new state of the core.
|
||||||
"""
|
"""
|
||||||
msg_id = lib.dc_prepare_msg(self.account._dc_context, self.id, msg._dc_msg)
|
msg_id = lib.dc_prepare_msg(self.account._dc_context, self.id, msg._dc_msg)
|
||||||
if msg_id == 0:
|
if msg_id == 0:
|
||||||
raise ValueError("message could not be prepared")
|
raise ValueError("message could not be prepared")
|
||||||
# invalidate passed in message which is not safe to use anymore
|
# modify message in place to avoid bad state for the caller
|
||||||
msg._dc_msg = msg.id = None
|
msg._dc_msg = Message.from_db(self.account, msg_id)._dc_msg
|
||||||
return Message.from_db(self.account, msg_id)
|
return msg
|
||||||
|
|
||||||
def prepare_message_file(self, path, mime_type=None, view_type="file"):
|
def prepare_message_file(self, path, mime_type=None, view_type="file"):
|
||||||
""" prepare a message for sending and return the resulting Message instance.
|
""" prepare a message for sending and return the resulting Message instance.
|
||||||
|
|||||||
Reference in New Issue
Block a user