feat(mail): Improve mail search (advanced search)

This commit is contained in:
smizrahi
2024-07-02 11:12:54 +02:00
parent f621d97289
commit ed951667ec
2 changed files with 7 additions and 32 deletions
+5 -30
View File
@@ -531,8 +531,7 @@
searchString = [NSString stringWithFormat: @"(date >= (NSCalendarDate)\"%@\" AND date <= (NSCalendarDate)\"%@\")", dateFrom, dateTo];
} else if ([searchBy isEqualToString: @"attachment"]) {
// Attachment
// Not possible with imap search, check in getUIDsInFolder method
// The attachments must be checked in headers
searchString = [NSString stringWithFormat: @"(text = 'attachment;') AND (text = 'filename')"];
} else if ([searchBy isEqualToString: @"favorite"]) {
// Favorite
flaggedOnly = YES;
@@ -552,16 +551,15 @@
searchString = [NSString stringWithFormat: @"%@ OR", searchString];
}
searchString = [NSString stringWithFormat: @"%@ (subject doesContain: '%@' OR body doesContain: '%@')",
searchString, searchInput, searchInput];
searchString = [NSString stringWithFormat: @"%@ (subject doesContain: '%@' OR body doesContain: '%@' OR text = 'filename=*%@*')",
searchString, searchInput, searchInput, searchInput];
j++;
}
searchString = [NSString stringWithFormat: @"%@)", searchString];
} else {
searchString = [NSString stringWithFormat: @"(subject doesContain: '%@' OR body doesContain: '%@')",
searchInput, searchInput];
searchString = [NSString stringWithFormat: @"(subject doesContain: '%@' OR body doesContain: '%@' OR text = 'filename=*%@*')",
searchInput, searchInput, searchInput];
}
} else if ([searchBy isEqualToString: @"not_contains"]) {
// Not contains
searchInput = [searchInput stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
@@ -891,29 +889,6 @@
headers = [self getHeadersForUIDs: [a subarrayWithRange: r]
inFolder: folder];
// This part is used to filter attachements when searching
// There is no way to filter only attachments when using imap SEARCH
if (onlyAttachments) {
tmpHeaders = [NSMutableArray arrayWithArray: headers];
tmpUids = [NSMutableArray arrayWithArray: uids];
for (i = ([tmpHeaders count] - 1); i > 0; i--) {
// Search for no attachment
if (0 == [[[tmpHeaders objectAtIndex: i] objectAtIndex: 1] intValue]) {
uid = [[tmpHeaders objectAtIndex: i] objectAtIndex: 10]; // Uid
[tmpHeaders removeObjectAtIndex: i];
for (j = ([tmpUids count] - 1); j >= 0; j--) {
if ([uid isEqual: [tmpUids objectAtIndex: j]]) {
[tmpUids removeObjectAtIndex: j]; // -1 for header
}
}
}
}
headers = [tmpHeaders copy];
uids = [tmpUids copy];
}
[data setObject: headers forKey: @"headers"];
}
@@ -512,13 +512,13 @@
</div>
<!-- <md-checkbox
<md-checkbox
ng-model="dialogCtrl.mainController.searchForm.attachements"
ng-true-value="1"
ng-false-value="0"
label:aria-label="With attachments">
<var:string label:value="With attachments"/>
</md-checkbox> -->
</md-checkbox>
<md-checkbox
ng-model="dialogCtrl.mainController.searchForm.favorite"