diff --git a/deltachat-jsonrpc/src/api/types/events.rs b/deltachat-jsonrpc/src/api/types/events.rs index 73862631b..fb54688fb 100644 --- a/deltachat-jsonrpc/src/api/types/events.rs +++ b/deltachat-jsonrpc/src/api/types/events.rs @@ -192,8 +192,7 @@ pub enum EventType { msg_id: u32, }, - /// A single message is read by the receiver. State changed from DC_STATE_OUT_DELIVERED to - /// DC_STATE_OUT_MDN_RCVD, see `Message.state`. + /// A single message is read by a receiver. #[serde(rename_all = "camelCase")] MsgRead { /// ID of the chat which the message belongs to. @@ -201,6 +200,12 @@ pub enum EventType { /// ID of the message that was read. msg_id: u32, + + /// Read for the first time (e.g. by just one group member + /// / channel subscriber). + /// State changed from DC_STATE_OUT_DELIVERED to + /// DC_STATE_OUT_MDN_RCVD, see dc_msg_get_state(). + first_time: bool, }, /// A single message was deleted. @@ -540,9 +545,14 @@ impl From for EventType { chat_id: chat_id.to_u32(), msg_id: msg_id.to_u32(), }, - CoreEventType::MsgRead { chat_id, msg_id } => MsgRead { + CoreEventType::MsgRead { + chat_id, + msg_id, + first_time, + } => MsgRead { chat_id: chat_id.to_u32(), msg_id: msg_id.to_u32(), + first_time, }, CoreEventType::MsgDeleted { chat_id, msg_id } => MsgDeleted { chat_id: chat_id.to_u32(), diff --git a/src/events/payload.rs b/src/events/payload.rs index 82bf70517..223ba45d0 100644 --- a/src/events/payload.rs +++ b/src/events/payload.rs @@ -171,14 +171,19 @@ pub enum EventType { msg_id: MsgId, }, - /// A single message is read by the receiver. State changed from DC_STATE_OUT_DELIVERED to - /// DC_STATE_OUT_MDN_RCVD, see dc_msg_get_state(). + /// A single message is read by a receiver. MsgRead { /// ID of the chat which the message belongs to. chat_id: ChatId, /// ID of the message that was read. msg_id: MsgId, + + /// Read for the first time (e.g. by just one group member + /// / channel subscriber). + /// State changed from DC_STATE_OUT_DELIVERED to + /// DC_STATE_OUT_MDN_RCVD, see dc_msg_get_state(). + first_time: bool, }, /// A single message was deleted. diff --git a/src/mimeparser.rs b/src/mimeparser.rs index a2d07fa4d..bc2365004 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -2596,8 +2596,12 @@ async fn handle_mdn( (msg_id, from_id, timestamp_sent), ) .await?; + context.emit_event(EventType::MsgRead { + chat_id, + msg_id, + first_time: !has_mdns, + }); if !has_mdns { - context.emit_event(EventType::MsgRead { chat_id, msg_id }); // note(treefit): only matters if it is the last message in chat (but probably too expensive to check, debounce also solves it) chatlist_events::emit_chatlist_item_changed(context, chat_id); }