UnSubscribeConfirmpublic class UnSubscribeConfirm extends BaseCommand UnSubscribeConfirm handles the unsubscribe-confirm command.
It is configured by:
<command name="unsubscribe-confirm" class="UnSubscribeConfirm"/>
It uses the formatted text-based resources for its return mail body:
After formatting the text, the message is delivered with {@link #sendStandardReply}
This command basically sends a goodbye message and removes the user from the mailing list. |
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[]{"unsubscribeConfirm"})[0];
| public void | onCommand(org.apache.mailet.Mail mail)After ensuring that the user is currently subscribed, remove the user to the
mailing list, and send a goodbye message.
if (checkSubscriptionStatus(mail)) {
getUsersRepository().removeUser(mail.getSender().toString());
//send mail
Properties props = getStandardProperties();
props.put("SENDER_ADDR", mail.getSender().toString());
String confirmationMail = xmlResources.getString("text", props);
String subject = xmlResources.getString("goodbye.subscribe.address", props);
sendStandardReply(mail, subject, confirmationMail, null);
}
|
|