fix: take timestamp_rcvd into account in estimate_deletion_cnt

This did not affect actual message deletion,
because select_expired_messages already takes timestamp_rcvd
into account and does not delete system messages
that say "Messages are end-to-end encrypted" too early.

So it is a minor bug as estimate_deletion_cnt
is meant to only roughly estimate the number of messages
to be deleted. Still, there were no tests before,
so now estimate_deletion_cnt is tested.
This commit is contained in:
link2xt
2026-08-22 20:21:20 +00:00
committed by l
parent 48888898ee
commit 0b2ff5d0e2
2 changed files with 20 additions and 5 deletions
+5 -4
View File
@@ -2100,10 +2100,11 @@ pub async fn estimate_deletion_cnt(
.count(
"SELECT COUNT(*)
FROM msgs m
WHERE m.id > ?
AND timestamp < ?
AND chat_id != ?
AND chat_id != ? AND hidden = 0;",
WHERE m.id > ?1
AND timestamp < ?2 -- Sorting timestamp may be 0 for system messages
AND timestamp_rcvd < ?2 -- so we check 'received' timestamp as well.
AND chat_id != ?3
AND chat_id != ?4 AND hidden = 0;",
(
DC_MSG_ID_LAST_SPECIAL,
threshold_timestamp,