From 1b8bf4ed23f81ae2fadf7640770277902cbc56ae Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 25 Mar 2026 05:19:08 +0100 Subject: [PATCH] api: add JSON-RPC API markfresh_chat() --- deltachat-jsonrpc/src/api.rs | 13 +++++++++++-- .../src/deltachat_rpc_client/chat.py | 4 ++++ deltachat-rpc-client/tests/test_something.py | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index d95b0e05b..d57e83336 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -11,8 +11,8 @@ use deltachat::blob::BlobObject; use deltachat::calls::ice_servers; use deltachat::chat::{ self, add_contact_to_chat, forward_msgs, forward_msgs_2ctx, get_chat_media, get_chat_msgs, - get_chat_msgs_ex, marknoticed_all_chats, marknoticed_chat, remove_contact_from_chat, Chat, - ChatId, ChatItem, MessageListOptions, + get_chat_msgs_ex, markfresh_chat, marknoticed_all_chats, marknoticed_chat, + remove_contact_from_chat, Chat, ChatId, ChatItem, MessageListOptions, }; use deltachat::chatlist::Chatlist; use deltachat::config::{get_all_ui_config_keys, Config}; @@ -1249,6 +1249,15 @@ impl CommandApi { marknoticed_chat(&ctx, ChatId::new(chat_id)).await } + /// Marks the last incoming message in the chat as _fresh_. + /// + /// UI can use this to offer a "mark unread" option, + /// so that already noticed chats get a badge counter again. + async fn markfresh_chat(&self, account_id: u32, chat_id: u32) -> Result<()> { + let ctx = self.get_context(account_id).await?; + markfresh_chat(&ctx, ChatId::new(chat_id)).await + } + /// Returns the message that is immediately followed by the last seen /// message. /// From the point of view of the user this is effectively diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/chat.py b/deltachat-rpc-client/src/deltachat_rpc_client/chat.py index 556af9c05..a4dae751a 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/chat.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/chat.py @@ -219,6 +219,10 @@ class Chat: """Mark all messages in this chat as noticed.""" self._rpc.marknoticed_chat(self.account.id, self.id) + def mark_fresh(self) -> None: + """Mark the last incoming message in the chat as fresh.""" + self._rpc.markfresh_chat(self.account.id, self.id) + def add_contact(self, *contact: Union[int, str, Contact, "Account"]) -> None: """Add contacts to this group.""" from .account import Account diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 9f41b09f6..7b3708526 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -273,6 +273,9 @@ def test_chat(acfactory) -> None: assert group.get_messages() group.get_fresh_message_count() group.mark_noticed() + assert group.get_fresh_message_count() == 0 + group.mark_fresh() + assert group.get_fresh_message_count() > 0 assert group.get_contacts() assert group.get_past_contacts() == [] group.remove_contact(alice_contact_bob)