use of com.zimbra.cs.mailbox.ContactRankings in project zm-mailbox by Zimbra.
the class ContactRankingTest method executeBasic.
@Override
protected boolean executeBasic(MailAdapter mail, Arguments args, SieveContext ctx) throws SieveException {
assert (headers != null);
if (mail instanceof DummyMailAdapter) {
return true;
}
if (!(mail instanceof ZimbraMailAdapter)) {
return false;
}
Mailbox mbox = ((ZimbraMailAdapter) mail).getMailbox();
List<InternetAddress> addrs = new ArrayList<InternetAddress>();
for (String header : headers) {
for (String value : mail.getHeader(header)) {
addrs.add(new InternetAddress(value));
}
}
try {
ContactRankings ranking = new ContactRankings(mbox.getAccountId());
for (InternetAddress addr : addrs) {
if (ranking.query(addr.getAddress()) > 0) {
return true;
}
}
} catch (ServiceException e) {
ZimbraLog.filter.error("Failed to lookup ranking", e);
}
return false;
}
Aggregations