diff options
| author | cotton | 1998-11-21 17:40:11 +0000 |
|---|---|---|
| committer | cotton | 1998-11-21 17:40:11 +0000 |
| commit | b3b9d11a05c6b69d8786db177d058fe7115bd6ed (patch) | |
| tree | 62a8fdf5e2d9b3748a68aa06120f2f8f23d99089 | |
| parent | c4673a9a249262077384c71e146a8443d5bb1a2b (diff) | |
| download | mailman-b3b9d11a05c6b69d8786db177d058fe7115bd6ed.tar.gz mailman-b3b9d11a05c6b69d8786db177d058fe7115bd6ed.tar.zst mailman-b3b9d11a05c6b69d8786db177d058fe7115bd6ed.zip | |
I should have broken this up into 2 checkins because it implements one
fix and one addition. Sorry, i realized that too late.
This change adds another list conifg variable "admin_notify_mchanges",
which is a boolean 0 or 1 and specifies whether or not the list admin
gets notifications of subscriptions and unsubscriptions.
The functions MailList.DeleteMember and MailList.ApprovedAddMember
trigger the delivery if it is turned on for the list or passed in as
an optional argument. This way, it is the duty of programs/code that
do mass subscriptions/unsubscriptions where this notification may not
be appropriate to specify that in the call to .DeleteMember or
.ApprovedAddMember.
There are 2 new templates, adminsubscribeack.txt and
adminunsubscribeack.txt which are used in sending these
notifications.
Defaults.py.in has a variable "DEFAULT_ADMIN_NOTIFY_MCHANGES" which is
set to 0 so that old lists will act the same by default, and the data
version is up'ed to 12. versions.py sets the variable if it's not
already there for a list. The config info for the admin cgi program
for this new variable is set right after the variable for immediate
notifications.
The second change is a fix where ApprovedAddMember was calling a
"self.Save()", which made mass subscribe situiations really far too
slow. I removed the .Save() from there and added it to the more outer
level code in the following places:
bin/convert_list
Mailman/ListAdmin.py
Mailman/MailCommandHandler.py
Mailman/Cgi/admin.py
Note that since AddMember can trigger a call to ApprovedAddMember, all
the places where AddMember is called needed a .Save() added as well.
I need to add a call to .Save() for Mailman/Cgi/subscribe.py as well
and will do that in a moment.
scott
| -rw-r--r-- | Mailman/Cgi/admin.py | 1 | ||||
| -rw-r--r-- | Mailman/Defaults.py.in | 7 | ||||
| -rw-r--r-- | Mailman/ListAdmin.py | 1 | ||||
| -rw-r--r-- | Mailman/MailCommandHandler.py | 1 | ||||
| -rw-r--r-- | Mailman/MailList.py | 38 | ||||
| -rw-r--r-- | Mailman/versions.py | 6 | ||||
| -rwxr-xr-x | bin/convert_list | 1 | ||||
| -rw-r--r-- | templates/adminsubscribeack.txt | 9 | ||||
| -rw-r--r-- | templates/adminunsubscribeack.txt | 9 |
9 files changed, 69 insertions, 4 deletions
diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py index 718f8e20a..bc2b0989d 100644 --- a/Mailman/Cgi/admin.py +++ b/Mailman/Cgi/admin.py @@ -763,6 +763,7 @@ def ChangeOptions(lst, category, cgi_info, document): document.AddItem(Header(5, "Successfully Subscribed:")) document.AddItem(apply(UnorderedList, tuple((subscribe_success)))) document.AddItem("<p>") + dirty = 1 if subscribe_errors: document.AddItem(Header(5, "Error Subscribing:")) items = map(lambda x: "%s -- %s" % (x[0], x[1]), subscribe_errors) diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in index 12e7b04a8..db3d2c8d3 100644 --- a/Mailman/Defaults.py.in +++ b/Mailman/Defaults.py.in @@ -110,6 +110,11 @@ DEFAULT_MAIL_COMMANDS_MAX_LINES = 25 # Is admin notified of admin requests immediately by mail, as well as by # daily pending-request reminder? DEFAULT_ADMIN_IMMED_NOTIFY = 1 +# +# Is admin notified of subscribes/unsububscribes? +# +DEFAULT_ADMIN_NOTIFY_MCHANGES = 0 + DEFAULT_MODERATED = 0 # Bounce if 'to' or 'cc' fields don't explicitly name list (anti-spam)? @@ -269,4 +274,4 @@ PRIVATE_ARCHIVE_FILE_DIR = os.path.join(PREFIX, 'archives/private') VERSION = '@VERSION@' # Data file version number -DATA_FILE_VERSION = 11 +DATA_FILE_VERSION = 12 diff --git a/Mailman/ListAdmin.py b/Mailman/ListAdmin.py index 33ee13e36..aea0f7dba 100644 --- a/Mailman/ListAdmin.py +++ b/Mailman/ListAdmin.py @@ -172,6 +172,7 @@ class ListAdmin: else: try: self.ApprovedAddMember(destination_email, pw, digest) + self.Save() except Errors.MMAlreadyAMember: pass diff --git a/Mailman/MailCommandHandler.py b/Mailman/MailCommandHandler.py index f78eda456..2400ace02 100644 --- a/Mailman/MailCommandHandler.py +++ b/Mailman/MailCommandHandler.py @@ -456,6 +456,7 @@ class MailCommandHandler: remote = mail.GetSender() try: self.AddMember(subscribe_address, password, digest, remote) + self.Save() except Errors.MMSubscribeNeedsConfirmation: # # the confirmation message that's been sent takes place diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 0ca5b1714..7917e8356 100644 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -191,6 +191,8 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, self.posters = [] self.forbidden_posters = [] self.admin_immed_notify = mm_cfg.DEFAULT_ADMIN_IMMED_NOTIFY + self.admin_notify_mchanges = \ + mm_cfg.DEFAULT_ADMIN_NOTIFY_MCHANGES self.moderated = mm_cfg.DEFAULT_MODERATED self.require_explicit_destination = \ mm_cfg.DEFAULT_REQUIRE_EXPLICIT_DESTINATION @@ -373,6 +375,9 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, " option causes notices to be sent immediately on the arrival" " of new requests, as well."), + ('admin_notify_mchanges', mm_cfg.Radio, ('No', 'Yes'), 0, + 'Should administrator get notices of subscribes/unsubscribes?'), + ('dont_respond_to_post_requests', mm_cfg.Radio, ('Yes', 'No'), 0, 'Send mail to poster when their posting is held for approval?', @@ -774,12 +779,17 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, - def ApprovedAddMember(self, name, password, digest, ack=None): + def ApprovedAddMember(self, name, password, digest, ack=None, admin_notif=None): if ack is None: if self.send_welcome_msg: ack = 1 else: ack = 0 + if admin_notif is None: + if self.admin_notify_mchanges: + admin_notif = 1 + else: + admin_notif = 0 name = Utils.LCDomain(name) if self.IsMember(name): raise Errors.MMAlreadyAMember @@ -794,9 +804,17 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, self.LogMsg("subscribe", "%s: new%s %s", self._internal_name, kind, name) self.passwords[name] = password - self.Save() if ack: self.SendSubscribeAck(name, password, digest) + if admin_notif: + import Message + txt = Utils.maketext("adminsubscribeack.txt", + {"mmowner": mm_cfg.MAILMAN_OWNER, + "admin_email": self.GetAdminEmail(), + "listname": self.real_name, + "member": name}, 1) + msg = Message.IncomingMessage(txt) + self.DeliverToOwner(msg, self.owner) def ProcessConfirmation(self, cookie): @@ -813,7 +831,7 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, - def DeleteMember(self, name, whence=None): + def DeleteMember(self, name, whence=None, admin_notif=None): self.IsListInitialized() # FindMatchingAddresses *should* never return more than 1 address. # However, should log this, just to make sure. @@ -846,6 +864,20 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, self.SendUnsubscribeAck(name) self.ClearBounceInfo(name) self.Save() + if admin_notif is None: + if self.admin_notify_mchanges: + admin_notif = 1 + else: + admin_notif = 0 + if admin_notif: + import Message + txt = Utils.maketext("adminunsubscribeack.txt", + {"mmowner": mm_cfg.MAILMAN_OWNER, + "admin_email": self.GetAdminEmail(), + "listname": self.real_name, + "member": name}, 1) + msg = Message.IncomingMessage(txt) + self.DeliverToOwner(msg, self.owner) if whence: whence = "; %s" % whence else: whence = "" self.LogMsg("subscribe", "%s: deleted %s%s", diff --git a/Mailman/versions.py b/Mailman/versions.py index c0d1f4d50..b145187ef 100644 --- a/Mailman/versions.py +++ b/Mailman/versions.py @@ -115,6 +115,12 @@ def UpdateOldVars(l, stored_state): for dm in l.digest_members: dmembers[dm] = 1 l.digest_members = dmembers + # + # set admin_notify_mchanges + # + if not hasattr(l, "admin_notify_mchanges"): + setatrr(l, "admin_notify_mchanges", + mm_cfg.DEFAULT_ADMIN_NOTIFY_MCHANGES) def UpdateOldUsers(l): diff --git a/bin/convert_list b/bin/convert_list index 0934be9f0..a9490e558 100755 --- a/bin/convert_list +++ b/bin/convert_list @@ -195,6 +195,7 @@ def main(): for member in dmembers: AddMember(ml, member, 1, send_welcome_msg) + ml.Save() if send_changes_msg: SendExplanation(ml, nmembers + dmembers) finally: diff --git a/templates/adminsubscribeack.txt b/templates/adminsubscribeack.txt new file mode 100644 index 000000000..89596087f --- /dev/null +++ b/templates/adminsubscribeack.txt @@ -0,0 +1,9 @@ +From %(mmowner)s +From: %(mmowner)s +To: %(admin_email)s +Subject: %(listname)s Subscribe Notification + + +%(member)s has been successfully subscribed to %(listname)s. + + diff --git a/templates/adminunsubscribeack.txt b/templates/adminunsubscribeack.txt new file mode 100644 index 000000000..2bf4d2f46 --- /dev/null +++ b/templates/adminunsubscribeack.txt @@ -0,0 +1,9 @@ +From %(mmowner)s +From: %(mmowner)s +To: %(admin_email)s +Subject: %(listname)s Unsubscribe Notification + + +%(member)s has been removed from %(listname)s. + + |
