mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 13:36:30 +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 =
|
||||
folders
|
||||
.iter()
|
||||
.find(|folder| match get_folder_meaning(folder) {
|
||||
FolderMeaning::SentObjects => true,
|
||||
_ => false,
|
||||
});
|
||||
let sentbox_folder = folders
|
||||
.iter()
|
||||
.find(|folder| match get_folder_meaning(folder) {
|
||||
FolderMeaning::SentObjects => true,
|
||||
_ => 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);
|
||||
|
||||
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 {
|
||||
if folder_name.attributes().is_empty() {
|
||||
return FolderMeaning::Unknown;
|
||||
}
|
||||
|
||||
let mut res = FolderMeaning::Unknown;
|
||||
let special_names = vec!["\\Spam", "\\Trash", "\\Drafts", "\\Junk"];
|
||||
|
||||
for attr in folder_name.attributes() {
|
||||
if let NameAttribute::Custom(ref label) = attr {
|
||||
if special_names.iter().any(|s| *s == label) {
|
||||
res = FolderMeaning::Other;
|
||||
return FolderMeaning::Other;
|
||||
} else if label == "\\Sent" {
|
||||
res = FolderMeaning::SentObjects
|
||||
return FolderMeaning::SentObjects;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match res {
|
||||
FolderMeaning::Unknown => get_folder_meaning_by_name(folder_name),
|
||||
_ => res,
|
||||
}
|
||||
return FolderMeaning::Unknown;
|
||||
}
|
||||
|
||||
fn precheck_imf(
|
||||
|
||||
Reference in New Issue
Block a user