Skip to content

Commit

Permalink
feat(mail): Improve mail search (advanced search)
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodySlum committed Jul 2, 2024
1 parent f621d97 commit ed95166
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
35 changes: 5 additions & 30 deletions UI/MailerUI/UIxMailListActions.m
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,7 @@ - (EOQualifier *) searchQualifier
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;
Expand All @@ -552,16 +551,15 @@ - (EOQualifier *) searchQualifier
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:@"\\'"];
Expand Down Expand Up @@ -891,29 +889,6 @@ - (NSDictionary *) getUIDsInFolder: (SOGoMailFolder *) folder
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"];
}

Expand Down
4 changes: 2 additions & 2 deletions UI/Templates/MailerUI/UIxMailFolderTemplate.wox
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ed95166

Please sign in to comment.