From c7fbfcc85ce953c398cafc5d3d7df13ccc997e5e Mon Sep 17 00:00:00 2001 From: Michael Hierweck Date: Fri, 8 Sep 2017 12:43:24 +0200 Subject: [PATCH] Maybe fixed: update relay_recipients when email address is created or deleted. --- .../email/EMailAddressProcessorFactory.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java b/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java index 0a32662..e648957 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java @@ -22,11 +22,11 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { Pac pac = email.getDomain().getUser().getPac(); CompoundProcessor cp = new CompoundProcessor(); cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", - email.getFullDomain() + " -" ) ); - WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); + email.getFullDomain() + " -" ) ); Config config = Config.getInstance(); cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", email.getEMailAddress() + " " + email.getTarget() ) ); + WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); for (String queueName : config.getProperty("queues.mail").split(",")) { waitingTasksProcessor.appendProcessor(queueName, new ShellProcessor( "postmap -r -i /etc/postfix-mailin/relayrecipients", email.getEMailAddress() + " anything" ), "Add to relayrecipients" ); @@ -35,11 +35,9 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { String domName = email.getDomain().getName(); for (String queueName : config.getProperty("queues.mail").split(",")) { waitingTasksProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net"); - } - return waitingTasksProcessor; - } else { - return cp; + } } + return waitingTasksProcessor; } public Processor createUpdateProcessor(EntityManager em, T entity) { @@ -60,8 +58,7 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/relayrecipients" ), "Remove from relayrecipients" ); } - int emailAddressCount = emailAddressCount(em, email); - if (emailAddressCount == 0) { + if (emailAddressCount(em, email) == 0) { // remove the domain from virtual.db String fullDomain = email.getFullDomain(); cp.appendProcessor( @@ -69,10 +66,8 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { for (String queueName : config.getProperty("queues.mail").split(",")) { waitingTasksProcessor.appendProcessor(queueName, createMailinDeleteProcessor(fullDomain), queueName + ".hostsharing.net"); } - return waitingTasksProcessor; - } else { - return cp; } + return waitingTasksProcessor; } private int emailAddressCount(EntityManager em, EMailAddress email) {