mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-09-11 06:24:19 +08:00
Case insensitive INBOX on fileinto (fixes #763)
This commit is contained in:
parent
51c8f7b279
commit
39d0a168d4
2 changed files with 20 additions and 7 deletions
|
@ -15,6 +15,8 @@ use trc::AddContext;
|
|||
|
||||
use crate::{auth::acl::EffectiveAcl, JMAP};
|
||||
|
||||
use super::INBOX_ID;
|
||||
|
||||
impl JMAP {
|
||||
pub async fn mailbox_get(
|
||||
&self,
|
||||
|
@ -317,16 +319,27 @@ impl JMAP {
|
|||
}
|
||||
|
||||
let mut filter = Vec::with_capacity(path.len() + 2);
|
||||
let mut has_inbox = false;
|
||||
filter.push(Filter::Or);
|
||||
for &item in &path {
|
||||
filter.push(Filter::eq(Property::Name, item));
|
||||
for (pos, item) in path.iter().enumerate() {
|
||||
if pos == 0 && item.eq_ignore_ascii_case("inbox") {
|
||||
has_inbox = true;
|
||||
} else {
|
||||
filter.push(Filter::eq(Property::Name, *item));
|
||||
}
|
||||
}
|
||||
filter.push(Filter::End);
|
||||
|
||||
let document_ids = self
|
||||
.filter(account_id, Collection::Mailbox, filter)
|
||||
.await?
|
||||
.results;
|
||||
let mut document_ids = if filter.len() > 2 {
|
||||
self.filter(account_id, Collection::Mailbox, filter)
|
||||
.await?
|
||||
.results
|
||||
} else {
|
||||
RoaringBitmap::new()
|
||||
};
|
||||
if has_inbox {
|
||||
document_ids.insert(INBOX_ID);
|
||||
}
|
||||
if exact_match && (document_ids.len() as usize) < path.len() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ if not mailboxexists ["Drafts", "Sent Items"] {
|
|||
}
|
||||
|
||||
# File into new mailboxes using flags
|
||||
fileinto :create "Inbox / Folder ";
|
||||
fileinto :create "INBOX / Folder ";
|
||||
fileinto :flags ["$important", "$seen"] :create "My/Nested/Mailbox/with/multiple/levels";
|
||||
|
||||
# Make sure all mailboxes were created
|
||||
|
|
Loading…
Add table
Reference in a new issue