use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class FlaggedTest method executeBasic.
@Override
protected boolean executeBasic(MailAdapter mail, Arguments args, SieveContext ctx) throws SieveException {
assert (flags != null);
if (mail instanceof DummyMailAdapter) {
return true;
}
if (!(mail instanceof ZimbraMailAdapter)) {
return false;
}
ZimbraMailAdapter adapter = (ZimbraMailAdapter) mail;
// check actions already taken by a previous filter
for (Action action : adapter.getActions()) {
if (action instanceof ActionFlag) {
if (flags.contains(action)) {
return true;
}
}
}
// check the message's flags if this filter is running against the existing messages
Message msg = adapter.getMessage();
if (msg != null) {
int bitmask = msg.getFlagBitmask();
return bitmask == FilterUtil.getFlagBitmask(flags, bitmask);
}
return false;
}
use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class LinkedInTest method executeBasic.
@Override
protected boolean executeBasic(MailAdapter mail, Arguments args, SieveContext ctx) throws SieveException {
if (mail instanceof DummyMailAdapter) {
return true;
}
if (!(mail instanceof ZimbraMailAdapter)) {
return false;
}
ZimbraMailAdapter adapter = (ZimbraMailAdapter) mail;
ParsedAddress sender = adapter.getParsedMessage().getParsedSender();
if (!Strings.isNullOrEmpty(sender.emailPart) && ADDRESSES.contains(sender.emailPart.toLowerCase())) {
return true;
}
return false;
}
use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class HeaderTest method match.
protected boolean match(MailAdapter mail, String comparator, String matchType, List<String> headerNames, List<String> keys, SieveContext context) throws SieveException {
if (mail instanceof DummyMailAdapter) {
return true;
}
if (!(mail instanceof ZimbraMailAdapter)) {
return false;
}
ZimbraMailAdapter zma = (ZimbraMailAdapter) mail;
if (matchType.equals(MatchTypeTags.MATCHES_TAG)) {
try {
evaluateVarExp(zma, headerNames, SourceType.HEADER, keys);
} catch (MessagingException e) {
throw new SieveException("Exception occured while evaluating variable expression.", e);
}
}
// Iterate over the header names looking for a match
boolean isMatched = false;
Iterator<String> headerNamesIter = headerNames.iterator();
while (!isMatched && headerNamesIter.hasNext()) {
List<String> values = zma.getMatchingHeader(headerNamesIter.next());
if (MatchTypeTags.CONTAINS_TAG.equals(matchType) && values != null && values.isEmpty()) {
isMatched = false;
} else {
isMatched = match(comparator, matchType, values, keys, context);
}
}
return isMatched;
}
use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class HeaderTest method replaceVariables.
/**
* @param keys
* @param mail
* @return
* @throws SyntaxException
*/
public static List<String> replaceVariables(List<String> keys, MailAdapter mail) throws SyntaxException {
List<String> replacedVariables = new ArrayList<String>();
if (!(mail instanceof ZimbraMailAdapter)) {
return replacedVariables;
}
ZimbraMailAdapter zma = (ZimbraMailAdapter) mail;
for (String key : keys) {
String temp = FilterUtil.replaceVariables(zma, key);
replacedVariables.add(temp);
}
return replacedVariables;
}
Aggregations