diff options
| author | mailman | 1998-05-20 17:13:40 +0000 |
|---|---|---|
| committer | mailman | 1998-05-20 17:13:40 +0000 |
| commit | 40e4dcc25da8367a214d12ef65166bd3bc57942f (patch) | |
| tree | 435b7331baf5c75db8fd3ddf0ce0f24907fc4689 | |
| parent | a41c223e09519af43a4b4a2f4c9c035797510a0c (diff) | |
| download | mailman-40e4dcc25da8367a214d12ef65166bd3bc57942f.tar.gz mailman-40e4dcc25da8367a214d12ef65166bd3bc57942f.tar.zst mailman-40e4dcc25da8367a214d12ef65166bd3bc57942f.zip | |
Do not send "user disabled" notices to admin when user is already
disabled. The idea is that numerous outstanding bounces do not each
require renotification of the admin.
DisableBouncingAddress(), RemoveBouncingAddress(): changed return
signatures to indicate whether email notification is necessary for
this action, and in Disable version, indicate not necessary when user
is already disabled. In all other cases, notification is indicated,
whatever the status.
| -rw-r--r-- | Mailman/Bouncer.py | 52 | ||||
| -rw-r--r-- | modules/mm_bouncer.py | 52 |
2 files changed, 70 insertions, 34 deletions
diff --git a/Mailman/Bouncer.py b/Mailman/Bouncer.py index 11444119f..ef7b6cf2e 100644 --- a/Mailman/Bouncer.py +++ b/Mailman/Bouncer.py @@ -1,6 +1,6 @@ "Handle delivery bounce messages, doing filtering when list is set for it." -__version__ = "$Revision: 467 $" +__version__ = "$Revision: 529 $" # It's possible to get the mail-list senders address (list-admin) in the # bounce list. You probably don't want to have list mail sent to that @@ -122,17 +122,19 @@ class Bouncer: if self.automatic_bounce_action == 0: return elif self.automatic_bounce_action == 1: - succeeded = self.DisableBouncingAddress(addr) + # Only send if call works ok. + (succeeded, send) = self.DisableBouncingAddress(addr) did = "disabled" - send = 1 elif self.automatic_bounce_action == 2: - succeeded = self.DisableBouncingAddress(addr) + (succeeded, send) = self.DisableBouncingAddress(addr) did = "disabled" + # Never send. send = 0 elif self.automatic_bounce_action == 3: - succeeded = self.RemoveBouncingAddress(addr) - did = "removed" + (succeeded, send) = self.RemoveBouncingAddress(addr) + # Always send. send = 1 + did = "removed" if send: if succeeded != 1: negative="not " @@ -170,40 +172,53 @@ class Bouncer: % mm_cfg.MAILMAN_OWNER], text = text) def DisableBouncingAddress(self, addr): + """Disable delivery for bouncing user address. + + Returning success and notification status.""" if not self.IsMember(addr): reason = "User not found." self.LogMsg("bounce", "%s: NOT disabled %s: %s", self.real_name, addr, reason) - return reason + return reason, 1 try: - self.SetUserOption(addr, mm_cfg.DisableDelivery, 1) - self.LogMsg("bounce", "%s: disabled %s", self.real_name, addr) - self.Save() - return 1 + if self.GetUserOption(addr, mm_cfg.DisableDelivery): + # No need to send out notification if they're already disabled. + self.LogMsg("bounce", + "%s: already disabled %s", self.real_name, addr) + return 1, 0 + else: + self.SetUserOption(addr, mm_cfg.DisableDelivery, 1) + self.LogMsg("bounce", + "%s: disabled %s", self.real_name, addr) + self.Save() + return 1, 1 except mm_err.MMNoSuchUserError: self.LogMsg("bounce", "%s: NOT disabled %s: %s", self.real_name, addr, mm_err.MMNoSuchUserError) self.ClearBounceInfo(addr) self.Save() - return mm_err.MMNoSuchUserError + return mm_err.MMNoSuchUserError, 1 def RemoveBouncingAddress(self, addr): + """Unsubscribe user with bouncing address. + + Returning success and notification status.""" if not self.IsMember(addr): reason = "User not found." self.LogMsg("bounce", "%s: NOT removed %s: %s", self.real_name, addr, reason) - return reason + return reason, 1 try: self.DeleteMember(addr, "bouncing addr") self.LogMsg("bounce", "%s: removed %s", self.real_name, addr) self.Save() - return 1 + return 1, 1 except mm_err.MMNoSuchUserError: self.LogMsg("bounce", "%s: NOT removed %s: %s", self.real_name, addr, mm_err.MMNoSuchUserError) self.ClearBounceInfo(addr) self.Save() - return mm_err.MMNoSuchUserError + return mm_err.MMNoSuchUserError, 1 # Return 0 if we couldn't make any sense of it, 1 if we handled it. def ScanMessage(self, msg): @@ -316,7 +331,11 @@ class Bouncer: did = [] for i in candidates: el = string.find(i, "...") - if el != -1: i = i[:el] + if el != -1: + i = i[:el] + if len(i) > 1 and i[0] == '<': + # Use stuff after open angle and before (optional) close: + i = regsub.splitx(i[1:], ">")[0] if i not in did: self.HandleBouncingAddress(i) did.append(i) @@ -325,7 +344,6 @@ class Bouncer: def ExtractBouncingAddr(self, line): email = regsub.splitx(line, '[^ \t@<>]+@[^ \t@<>]+\.[^ \t<>.]+')[1] if email[0] == '<': - # Remove what's within the angles. return regsub.splitx(email[1:], ">")[0] else: return email diff --git a/modules/mm_bouncer.py b/modules/mm_bouncer.py index 11444119f..ef7b6cf2e 100644 --- a/modules/mm_bouncer.py +++ b/modules/mm_bouncer.py @@ -1,6 +1,6 @@ "Handle delivery bounce messages, doing filtering when list is set for it." -__version__ = "$Revision: 467 $" +__version__ = "$Revision: 529 $" # It's possible to get the mail-list senders address (list-admin) in the # bounce list. You probably don't want to have list mail sent to that @@ -122,17 +122,19 @@ class Bouncer: if self.automatic_bounce_action == 0: return elif self.automatic_bounce_action == 1: - succeeded = self.DisableBouncingAddress(addr) + # Only send if call works ok. + (succeeded, send) = self.DisableBouncingAddress(addr) did = "disabled" - send = 1 elif self.automatic_bounce_action == 2: - succeeded = self.DisableBouncingAddress(addr) + (succeeded, send) = self.DisableBouncingAddress(addr) did = "disabled" + # Never send. send = 0 elif self.automatic_bounce_action == 3: - succeeded = self.RemoveBouncingAddress(addr) - did = "removed" + (succeeded, send) = self.RemoveBouncingAddress(addr) + # Always send. send = 1 + did = "removed" if send: if succeeded != 1: negative="not " @@ -170,40 +172,53 @@ class Bouncer: % mm_cfg.MAILMAN_OWNER], text = text) def DisableBouncingAddress(self, addr): + """Disable delivery for bouncing user address. + + Returning success and notification status.""" if not self.IsMember(addr): reason = "User not found." self.LogMsg("bounce", "%s: NOT disabled %s: %s", self.real_name, addr, reason) - return reason + return reason, 1 try: - self.SetUserOption(addr, mm_cfg.DisableDelivery, 1) - self.LogMsg("bounce", "%s: disabled %s", self.real_name, addr) - self.Save() - return 1 + if self.GetUserOption(addr, mm_cfg.DisableDelivery): + # No need to send out notification if they're already disabled. + self.LogMsg("bounce", + "%s: already disabled %s", self.real_name, addr) + return 1, 0 + else: + self.SetUserOption(addr, mm_cfg.DisableDelivery, 1) + self.LogMsg("bounce", + "%s: disabled %s", self.real_name, addr) + self.Save() + return 1, 1 except mm_err.MMNoSuchUserError: self.LogMsg("bounce", "%s: NOT disabled %s: %s", self.real_name, addr, mm_err.MMNoSuchUserError) self.ClearBounceInfo(addr) self.Save() - return mm_err.MMNoSuchUserError + return mm_err.MMNoSuchUserError, 1 def RemoveBouncingAddress(self, addr): + """Unsubscribe user with bouncing address. + + Returning success and notification status.""" if not self.IsMember(addr): reason = "User not found." self.LogMsg("bounce", "%s: NOT removed %s: %s", self.real_name, addr, reason) - return reason + return reason, 1 try: self.DeleteMember(addr, "bouncing addr") self.LogMsg("bounce", "%s: removed %s", self.real_name, addr) self.Save() - return 1 + return 1, 1 except mm_err.MMNoSuchUserError: self.LogMsg("bounce", "%s: NOT removed %s: %s", self.real_name, addr, mm_err.MMNoSuchUserError) self.ClearBounceInfo(addr) self.Save() - return mm_err.MMNoSuchUserError + return mm_err.MMNoSuchUserError, 1 # Return 0 if we couldn't make any sense of it, 1 if we handled it. def ScanMessage(self, msg): @@ -316,7 +331,11 @@ class Bouncer: did = [] for i in candidates: el = string.find(i, "...") - if el != -1: i = i[:el] + if el != -1: + i = i[:el] + if len(i) > 1 and i[0] == '<': + # Use stuff after open angle and before (optional) close: + i = regsub.splitx(i[1:], ">")[0] if i not in did: self.HandleBouncingAddress(i) did.append(i) @@ -325,7 +344,6 @@ class Bouncer: def ExtractBouncingAddr(self, line): email = regsub.splitx(line, '[^ \t@<>]+@[^ \t@<>]+\.[^ \t<>.]+')[1] if email[0] == '<': - # Remove what's within the angles. return regsub.splitx(email[1:], ">")[0] else: return email |
