use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class ZimbraVariablesCtrl method executeBasic.
@Override
protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context) throws SieveException {
if (!(mail instanceof ZimbraMailAdapter)) {
return null;
}
ZimbraMailAdapter mailAdapter = (ZimbraMailAdapter) mail;
for (Argument arg : arguments.getArgumentList()) {
if (arg instanceof TagArgument) {
TagArgument tag = (TagArgument) arg;
String tagValue = tag.getTag();
if (RESET.equalsIgnoreCase(tagValue)) {
mailAdapter.resetValues();
} else {
throw new SyntaxException("Invalid tag: [" + tagValue + "]");
}
}
}
return null;
}
use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class SetVariable method executeBasic.
@Override
protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context) throws SieveException {
if (!(mail instanceof ZimbraMailAdapter)) {
return null;
}
ZimbraMailAdapter mailAdapter = (ZimbraMailAdapter) mail;
Require.checkCapability(mailAdapter, CAPABILITY_VARIABLES);
this.validateArguments(arguments, context);
Map<String, String> existingVars = mailAdapter.getVariables();
List<String> matchedValues = mailAdapter.getMatchedValues();
String[] operations = new String[OPERATIONS_IDX];
String key = null;
String value = null;
int index = 0;
for (Argument a : arguments.getArgumentList()) {
if (a instanceof TagArgument) {
TagArgument tag = (TagArgument) a;
String tagValue = tag.getTag();
if (isValidModifier(tagValue)) {
checkCapability(mailAdapter, tagValue);
operations[getIndex(tagValue)] = tagValue.toLowerCase();
}
} else {
String argument = ((StringListArgument) a).getList().get(0);
if (index == 0) {
key = FilterUtil.handleQuotedAndEncodedVar(argument);
} else {
if (argument.contains("${")) {
value = FilterUtil.replaceVariables(mailAdapter, argument);
} else {
value = argument;
}
}
++index;
}
}
value = applyModifiers(value, operations);
mailAdapter.addVariable(key, value);
return null;
}
use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class Stop method executeBasic.
@Override
protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context) throws SieveException {
if (!(mail instanceof ZimbraMailAdapter)) {
return null;
}
ZimbraMailAdapter mailAdapter = (ZimbraMailAdapter) mail;
mailAdapter.setStop(true);
return super.executeBasic(mail, arguments, block, context);
}
use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class SocialcastTest 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;
ParsedMessage pm = adapter.getParsedMessage();
ParsedAddress sender = pm.getParsedSender();
if (!Strings.isNullOrEmpty(sender.emailPart) && sender.emailPart.endsWith("@socialcast.com")) {
try {
if (pm.getMimeMessage().getHeader("Reply-To", null) != null) {
// test if Reply-To exists
return true;
}
} catch (MessagingException ignore) {
}
}
return false;
}
use of com.zimbra.cs.filter.ZimbraMailAdapter in project zm-mailbox by Zimbra.
the class TwitterTest 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)) {
String email = sender.emailPart.toLowerCase();
if (email.equals("notify@twitter.com")) {
return true;
}
}
return false;
}
Aggregations