mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
@@ -86,6 +86,23 @@ class Message(object):
|
|||||||
"""set text of this message. """
|
"""set text of this message. """
|
||||||
lib.dc_msg_set_text(self._dc_msg, as_dc_charpointer(text))
|
lib.dc_msg_set_text(self._dc_msg, as_dc_charpointer(text))
|
||||||
|
|
||||||
|
@props.with_doc
|
||||||
|
def html(self):
|
||||||
|
"""html text of this messages (might be empty if not an html message). """
|
||||||
|
return from_dc_charpointer(
|
||||||
|
lib.dc_get_msg_html(self.account._dc_context, self.id)) or ""
|
||||||
|
|
||||||
|
def has_html(self):
|
||||||
|
"""return True if this message has an html part, False otherwise."""
|
||||||
|
return lib.dc_msg_has_html(self._dc_msg)
|
||||||
|
|
||||||
|
def set_html(self, html_text):
|
||||||
|
"""set the html part of this message.
|
||||||
|
|
||||||
|
It is possible to have text and html part at the same time.
|
||||||
|
"""
|
||||||
|
lib.dc_msg_set_html(self._dc_msg, as_dc_charpointer(html_text))
|
||||||
|
|
||||||
@props.with_doc
|
@props.with_doc
|
||||||
def filename(self):
|
def filename(self):
|
||||||
"""filename if there was an attachment, otherwise empty string. """
|
"""filename if there was an attachment, otherwise empty string. """
|
||||||
|
|||||||
@@ -816,6 +816,48 @@ class TestOnlineAccount:
|
|||||||
assert open(msg.filename).read() == content
|
assert open(msg.filename).read() == content
|
||||||
assert msg.filename.endswith(basename)
|
assert msg.filename.endswith(basename)
|
||||||
|
|
||||||
|
def test_html_message(self, acfactory, lp):
|
||||||
|
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||||
|
chat = acfactory.get_accepted_chat(ac1, ac2)
|
||||||
|
html_text = "<p>hello HTML world</p>"
|
||||||
|
|
||||||
|
lp.sec("ac1: prepare and send text message to ac2")
|
||||||
|
msg1 = chat.send_text("message0")
|
||||||
|
assert not msg1.has_html()
|
||||||
|
assert msg1.html == ""
|
||||||
|
|
||||||
|
lp.sec("wait for ac2 to receive message")
|
||||||
|
msg2 = ac2._evtracker.wait_next_incoming_message()
|
||||||
|
assert msg2.text == "message0"
|
||||||
|
assert not msg2.has_html()
|
||||||
|
assert msg2.html == ""
|
||||||
|
|
||||||
|
lp.sec("ac1: prepare and send HTML+text message to ac2")
|
||||||
|
msg1 = Message.new_empty(ac1, "text")
|
||||||
|
msg1.set_text("message1")
|
||||||
|
msg1.set_html(html_text)
|
||||||
|
msg1 = chat.send_msg(msg1)
|
||||||
|
assert msg1.has_html()
|
||||||
|
assert html_text in msg1.html
|
||||||
|
|
||||||
|
lp.sec("wait for ac2 to receive message")
|
||||||
|
msg2 = ac2._evtracker.wait_next_incoming_message()
|
||||||
|
assert msg2.text == "message1"
|
||||||
|
assert msg2.has_html()
|
||||||
|
assert html_text in msg2.html
|
||||||
|
|
||||||
|
lp.sec("ac1: prepare and send HTML-only message to ac2")
|
||||||
|
msg1 = Message.new_empty(ac1, "text")
|
||||||
|
msg1.set_html(html_text)
|
||||||
|
msg1 = chat.send_msg(msg1)
|
||||||
|
|
||||||
|
lp.sec("wait for ac2 to receive message")
|
||||||
|
msg2 = ac2._evtracker.wait_next_incoming_message()
|
||||||
|
assert "<p>" not in msg2.text
|
||||||
|
assert "hello HTML world" in msg2.text
|
||||||
|
assert msg2.has_html()
|
||||||
|
assert html_text in msg2.html
|
||||||
|
|
||||||
def test_mvbox_sentbox_threads(self, acfactory, lp):
|
def test_mvbox_sentbox_threads(self, acfactory, lp):
|
||||||
lp.sec("ac1: start with mvbox thread")
|
lp.sec("ac1: start with mvbox thread")
|
||||||
ac1 = acfactory.get_online_configuring_account(mvbox=True, move=True, sentbox=True)
|
ac1 = acfactory.get_online_configuring_account(mvbox=True, move=True, sentbox=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user