UnSubscribepublic class UnSubscribe extends BaseCommand UnSubscribe handles the unsubscribe command.
It is configured by:
<command name="unsubscribe" class="UnSubscribe"/>
It uses the formatted text-based resources for its return mail body:
After formatting the text, the message is delivered with {@link #sendStandardReply}
Note, prior to formatting and sending any text, the user is checked to see that they
are currently subscribed to this list. If so, they will be sent a confirmation mail to
be processed by {@link UnSubscribeConfirm} |
Fields Summary |
---|
protected org.apache.james.util.XMLResources | xmlResources |
Methods Summary |
---|
protected boolean | checkSubscriptionStatus(org.apache.mailet.Mail mail)Checks to see that this user is already subscribed, if not return false and send a message
MailAddress mailAddress = mail.getSender();
UsersRepository usersRepository = getUsersRepository();
if (!usersRepository.contains(mailAddress.toString())) {
getCommandListservManager().onError(mail,
"Invalid request",
xmlResources.getString("not.subscribed", getStandardProperties()));
return false;
}
return true;
| public void | init(org.apache.james.transport.mailets.ICommandListservManager commandListservManager, org.apache.avalon.framework.configuration.Configuration configuration)
super.init(commandListservManager, configuration);
xmlResources = initXMLResources(new String[]{"unsubscribe"})[0];
| public void | onCommand(org.apache.mailet.Mail mail)After ensuring that the user is currently subscribed, confirmation mail
will be sent to be processed by {@link UnSubscribeConfirm}.
if (checkSubscriptionStatus(mail)) {
//send confirmation mail
Properties props = getStandardProperties();
props.put("SENDER_ADDR", mail.getSender().toString());
String confirmationMail = xmlResources.getString("text", props);
String subject = xmlResources.getString("confirm.unsubscribe.subject", props);
String replyAddress = xmlResources.getString("confirm.unsubscribe.address", props);
sendStandardReply(mail, subject, confirmationMail, replyAddress);
}
|
|