Added cc: and bcc: search

pull/209/head
M66B 2 years ago
parent 0d62b0affa
commit fd9f278962

@ -1146,11 +1146,13 @@ This will result in searching like this:
("apple" AND "banana" AND NOT "cherry") OR "nuts" ("apple" AND "banana" AND NOT "cherry") OR "nuts"
``` ```
Since version 1.1979 it is possible to use these prefixes as a search expression: Since version 1.1980 it is possible to use these prefixes as a search expression:
``` ```
from:<email address> from:<email address>
to:<email address> to:<email address>
cc:<email address>
bcc:<email address>
keyword:<keyword> keyword:<keyword>
``` ```

@ -886,6 +886,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
private static final String FROM = "from:"; private static final String FROM = "from:";
private static final String TO = "to:"; private static final String TO = "to:";
private static final String CC = "cc:";
private static final String BCC = "bcc:";
private static final String KEYWORD = "keyword:"; private static final String KEYWORD = "keyword:";
boolean onServer() { boolean onServer() {
@ -903,6 +905,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
return true; return true;
else if (w.length() > TO.length() && w.startsWith(TO)) else if (w.length() > TO.length() && w.startsWith(TO))
return true; return true;
else if (w.length() > CC.length() && w.startsWith(CC))
return true;
else if (w.length() > BCC.length() && w.startsWith(BCC))
return true;
else if (w.length() > KEYWORD.length() && w.startsWith(KEYWORD)) else if (w.length() > KEYWORD.length() && w.startsWith(KEYWORD))
return true; return true;
@ -931,6 +937,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
List<String> opt = new ArrayList<>(); List<String> opt = new ArrayList<>();
List<String> andFrom = new ArrayList<>(); List<String> andFrom = new ArrayList<>();
List<String> andTo = new ArrayList<>(); List<String> andTo = new ArrayList<>();
List<String> andCc = new ArrayList<>();
List<String> andBcc = new ArrayList<>();
List<String> andKeyword = new ArrayList<>(); List<String> andKeyword = new ArrayList<>();
StringBuilder all = new StringBuilder(); StringBuilder all = new StringBuilder();
for (String w : search.trim().split("\\s+")) { for (String w : search.trim().split("\\s+")) {
@ -950,6 +958,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
andFrom.add(w.substring(FROM.length())); andFrom.add(w.substring(FROM.length()));
else if (w.length() > TO.length() && w.startsWith(TO)) else if (w.length() > TO.length() && w.startsWith(TO))
andTo.add(w.substring(TO.length())); andTo.add(w.substring(TO.length()));
else if (w.length() > CC.length() && w.startsWith(CC))
andCc.add(w.substring(CC.length()));
else if (w.length() > BCC.length() && w.startsWith(BCC))
andBcc.add(w.substring(BCC.length()));
else if (w.length() > KEYWORD.length() && w.startsWith(KEYWORD)) else if (w.length() > KEYWORD.length() && w.startsWith(KEYWORD))
andKeyword.add(w.substring(KEYWORD.length())); andKeyword.add(w.substring(KEYWORD.length()));
else { else {
@ -959,7 +971,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
} }
if (plus.size() + minus.size() + opt.size() + if (plus.size() + minus.size() + opt.size() +
andFrom.size() + andTo.size() + andKeyword.size() > 0) andFrom.size() +
andTo.size() + andCc.size() + andBcc.size() +
andKeyword.size() > 0)
search = all.toString(); search = all.toString();
// Yahoo! does not support keyword search, but uses the flags $Forwarded $Junk $NotJunk // Yahoo! does not support keyword search, but uses the flags $Forwarded $Junk $NotJunk
@ -978,9 +992,13 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
or.add(new FromStringTerm(search)); or.add(new FromStringTerm(search));
} }
if (andTo.size() > 0) { if (andTo.size() + andCc.size() + andBcc.size() > 0) {
for (String term : andTo) for (String term : andTo)
and.add(new RecipientStringTerm(Message.RecipientType.TO, term)); and.add(new RecipientStringTerm(Message.RecipientType.TO, term));
for (String term : andCc)
and.add(new RecipientStringTerm(Message.RecipientType.CC, term));
for (String term : andBcc)
and.add(new RecipientStringTerm(Message.RecipientType.BCC, term));
} else { } else {
if (in_recipients && !TextUtils.isEmpty(search)) { if (in_recipients && !TextUtils.isEmpty(search)) {
or.add(new RecipientStringTerm(Message.RecipientType.TO, search)); or.add(new RecipientStringTerm(Message.RecipientType.TO, search));

Loading…
Cancel
Save