Store vanished IMAP UIDs and WebDAV paths

This commit is contained in:
mdecimus
2025-05-29 13:38:41 +02:00
parent b793ed7ebb
commit 42fd7d4de1
25 changed files with 756 additions and 129 deletions

View File

@@ -7,6 +7,7 @@
use super::metadata::MessageData;
use crate::{cache::MessageCacheFetch, mailbox::*, message::metadata::MessageMetadata};
use common::{KV_LOCK_PURGE_ACCOUNT, Server, storage::index::ObjectIndexBuilder};
use jmap_proto::types::collection::VanishedCollection;
use jmap_proto::types::{collection::Collection, property::Property};
use std::future::Future;
use std::time::Duration;
@@ -64,15 +65,18 @@ impl EmailDeletion for Server {
&document_ids,
|document_id, data_| {
// Add changes to batch
let metadata = data_
.to_unarchived::<MessageData>()
.caused_by(trc::location!())?;
for mailbox in metadata.inner.mailboxes.iter() {
batch.log_vanished_item(
VanishedCollection::Email,
(mailbox.mailbox_id.to_native(), mailbox.uid.to_native()),
);
}
batch
.update_document(document_id)
.custom(
ObjectIndexBuilder::<_, ()>::new().with_current(
data_
.to_unarchived::<MessageData>()
.caused_by(trc::location!())?,
),
)
.custom(ObjectIndexBuilder::<_, ()>::new().with_current(metadata))
.caused_by(trc::location!())?
.tag(Property::MailboxIds, TagValue::Id(TOMBSTONE_ID))
.commit_point();

View File

@@ -603,4 +603,11 @@ impl ArchivedMessageData {
pub fn has_mailbox_id(&self, mailbox_id: u32) -> bool {
self.mailboxes.iter().any(|m| m.mailbox_id == mailbox_id)
}
pub fn message_uid(&self, mailbox_id: u32) -> Option<u32> {
self.mailboxes
.iter()
.find(|m| m.mailbox_id == mailbox_id)
.map(|m| m.uid.to_native())
}
}