From b872953bc510840d2c7feb21c639083764bab3c0 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 23 Jul 2023 19:38:52 +0000 Subject: [PATCH] fix(deltachat-jsonrpc): make MessageObject.text non-optional This is already non-optional on the `deltachat` crate side since --- deltachat-jsonrpc/src/api/types/message.rs | 4 ++-- deltachat-rpc-client/tests/test_something.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/deltachat-jsonrpc/src/api/types/message.rs b/deltachat-jsonrpc/src/api/types/message.rs index 01a433300..9e50d90eb 100644 --- a/deltachat-jsonrpc/src/api/types/message.rs +++ b/deltachat-jsonrpc/src/api/types/message.rs @@ -34,7 +34,7 @@ pub struct MessageObject { quote: Option, parent_id: Option, - text: Option, + text: String, has_location: bool, has_html: bool, view_type: MessageViewtype, @@ -180,7 +180,7 @@ impl MessageObject { from_id: message.get_from_id().to_u32(), quote, parent_id, - text: Some(message.get_text()).filter(|s| !s.is_empty()), + text: message.get_text(), has_location: message.has_location(), has_html: message.has_html(), view_type: message.get_viewtype().into(), diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 72c8630f9..6c2351ecf 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -101,6 +101,16 @@ async def test_account(acfactory) -> None: assert await alice.get_fresh_messages() assert await alice.get_next_messages() + # Test sending empty message. + assert len(await bob.wait_next_messages()) == 0 + await alice_chat_bob.send_text("") + messages = await bob.wait_next_messages() + assert len(messages) == 1 + message = messages[0] + snapshot = await message.get_snapshot() + assert snapshot.text == "" + await bob.mark_seen_messages([message]) + group = await alice.create_group("test group") await group.add_contact(alice_contact_bob) group_msg = await group.send_message(text="hello")