mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 02:16:29 +03:00
let dc_marknoticed_chat() also handle the virtual deaddrop chat
This commit is contained in:
@@ -1078,9 +1078,9 @@ int dc_estimate_deletion_cnt (dc_context_t* context, int from_ser
|
||||
* or badge counters eg. on the app-icon.
|
||||
* The list is already sorted and starts with the most recent fresh message.
|
||||
*
|
||||
* Messages belonging to muted chats are not returned,
|
||||
* as they should not be notified
|
||||
* and also a badge counters should not include messages of muted chats.
|
||||
* Messages belonging to muted chats or to the deaddrop are not returned;
|
||||
* these messages should not be notified
|
||||
* and also badge counters should not include these messages.
|
||||
*
|
||||
* To get the number of fresh messages for a single chat, muted or not,
|
||||
* use dc_get_fresh_msg_cnt().
|
||||
@@ -1104,7 +1104,8 @@ dc_array_t* dc_get_fresh_msgs (dc_context_t* context);
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as returned from dc_context_new().
|
||||
* @param chat_id The chat ID of which all messages should be marked as being noticed.
|
||||
* @param chat_id The chat ID of which all messages should be marked as being noticed
|
||||
* (this also works for the virtual chat ID DC_CHAT_ID_DEADDROP).
|
||||
*/
|
||||
void dc_marknoticed_chat (dc_context_t* context, uint32_t chat_id);
|
||||
|
||||
|
||||
26
src/chat.rs
26
src/chat.rs
@@ -1987,7 +1987,33 @@ pub(crate) async fn marknoticed_chat_if_older_than(
|
||||
}
|
||||
|
||||
pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<(), Error> {
|
||||
// for the virtual deaddrop chat-id,
|
||||
// mark all messages that will appear in the deaddrop as noticed
|
||||
if chat_id.is_deaddrop() {
|
||||
if context
|
||||
.sql
|
||||
.execute(
|
||||
"UPDATE msgs
|
||||
SET state=?1
|
||||
WHERE state=?2
|
||||
AND hidden=0
|
||||
AND chat_id IN (SELECT id FROM chats WHERE blocked=?3);",
|
||||
paramsv![
|
||||
MessageState::InNoticed,
|
||||
MessageState::InFresh,
|
||||
Blocked::Deaddrop
|
||||
],
|
||||
)
|
||||
.await?
|
||||
> 0
|
||||
{
|
||||
context.emit_event(EventType::MsgsNoticed(chat_id));
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// "WHERE" below uses the index `(state, hidden, chat_id)`, see get_fresh_msg_cnt() for reasoning
|
||||
// the additional SELECT statement may speed up things as no write-blocking is needed.
|
||||
let exists = context
|
||||
.sql
|
||||
.exists(
|
||||
|
||||
Reference in New Issue
Block a user