mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
smoother searching for sentbox
search for the sentbox in two passes: - first check the folder attributes - only if that fails, check for some known names this way, the sent-attribute always has precedence over the name; this was not the case before. moreover, this fixes an possibly wrong early exist when the attribute list is completely empty.
This commit is contained in:
@@ -1063,13 +1063,21 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let sentbox_folder =
|
let sentbox_folder = folders
|
||||||
folders
|
.iter()
|
||||||
.iter()
|
.find(|folder| match get_folder_meaning(folder) {
|
||||||
.find(|folder| match get_folder_meaning(folder) {
|
FolderMeaning::SentObjects => true,
|
||||||
FolderMeaning::SentObjects => true,
|
_ => false,
|
||||||
_ => false,
|
})
|
||||||
});
|
.or_else(|| {
|
||||||
|
info!(context, "can't find sentbox by attributes, checking names");
|
||||||
|
folders
|
||||||
|
.iter()
|
||||||
|
.find(|folder| match get_folder_meaning_by_name(folder) {
|
||||||
|
FolderMeaning::SentObjects => true,
|
||||||
|
_ => false,
|
||||||
|
})
|
||||||
|
});
|
||||||
info!(context, "sentbox folder is {:?}", sentbox_folder);
|
info!(context, "sentbox folder is {:?}", sentbox_folder);
|
||||||
|
|
||||||
let mut delimiter = ".";
|
let mut delimiter = ".";
|
||||||
@@ -1246,27 +1254,18 @@ fn get_folder_meaning_by_name(folder_name: &Name) -> FolderMeaning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_folder_meaning(folder_name: &Name) -> FolderMeaning {
|
fn get_folder_meaning(folder_name: &Name) -> FolderMeaning {
|
||||||
if folder_name.attributes().is_empty() {
|
|
||||||
return FolderMeaning::Unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut res = FolderMeaning::Unknown;
|
|
||||||
let special_names = vec!["\\Spam", "\\Trash", "\\Drafts", "\\Junk"];
|
let special_names = vec!["\\Spam", "\\Trash", "\\Drafts", "\\Junk"];
|
||||||
|
|
||||||
for attr in folder_name.attributes() {
|
for attr in folder_name.attributes() {
|
||||||
if let NameAttribute::Custom(ref label) = attr {
|
if let NameAttribute::Custom(ref label) = attr {
|
||||||
if special_names.iter().any(|s| *s == label) {
|
if special_names.iter().any(|s| *s == label) {
|
||||||
res = FolderMeaning::Other;
|
return FolderMeaning::Other;
|
||||||
} else if label == "\\Sent" {
|
} else if label == "\\Sent" {
|
||||||
res = FolderMeaning::SentObjects
|
return FolderMeaning::SentObjects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return FolderMeaning::Unknown;
|
||||||
match res {
|
|
||||||
FolderMeaning::Unknown => get_folder_meaning_by_name(folder_name),
|
|
||||||
_ => res,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn precheck_imf(
|
fn precheck_imf(
|
||||||
|
|||||||
Reference in New Issue
Block a user