changeset 3518:ef612c82bdfd

remove want_trivial completely, fix trivial notifications
author Johannes Berg <johannes AT sipsolutions DOT net>
date Tue, 22 Apr 2008 23:00:40 +0200
parents 41bfc5d6e3d3
children db35fff4d5ec
files MoinMoin/Page.py MoinMoin/events/emailnotify.py MoinMoin/events/jabbernotify.py
diffstat 3 files changed, 15 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Tue Apr 22 15:54:35 2008 +0200
+++ b/MoinMoin/Page.py	Tue Apr 22 23:00:40 2008 +0200
@@ -836,13 +836,11 @@
         @param request: the request object
         @keyword include_self: if 1, include current user (default: 0)
         @keyword return_users: if 1, return user instances (default: 0)
-        @keyword trivial: if 1, only include users who want trivial changes (default: 0)
         @rtype: dict
         @return: lists of subscribed email addresses in a dict by language key
         """
         include_self = kw.get('include_self', self.include_self)
         return_users = kw.get('return_users', 0)
-        trivial = kw.get('trivial', 0)
 
         # extract categories of this page
         pageList = self.getCategories(request)
@@ -858,8 +856,6 @@
         # get email addresses of the all wiki user which have a profile stored;
         # add the address only if the user has subscribed to the page and
         # the user is not the current editor
-        # Also, if the change is trivial (send email isn't ticked) only send email to users
-        # who want_trivial changes (typically Admins on public sites)
         userlist = user.getUserList(request)
         subscriber_list = {}
         for uid in userlist:
@@ -877,8 +873,6 @@
             # So it _should_ be "not (subscriber.email and return_users)" but that breaks at the moment.
             if not subscriber.email:
                 continue # skip empty email addresses
-            if trivial and not subscriber.want_trivial:
-                continue # skip uninterested subscribers
 
             # skip people not subscribed
             if not subscriber.isSubscribedTo(pageList):
--- a/MoinMoin/events/emailnotify.py	Tue Apr 22 15:54:35 2008 +0200
+++ b/MoinMoin/events/emailnotify.py	Tue Apr 22 23:00:40 2008 +0200
@@ -65,16 +65,19 @@
     return sendmail.sendmail(request, emails, data['subject'], data['body'], mail_from=from_address)
 
 
-def notify_subscribers(request, page, comment, trivial):
+def handle_page_change(event):
     """ Send email to all subscribers of given page.
 
-    @param comment: editor's comment given when saving the page
-    @param trivial: editor's suggestion that the change is trivial (Subscribers may ignore this)
+    @param event: event to notify about
     @rtype: string
     @return: message, indicating success or errors.
 
     """
-    subscribers = page.getSubscribers(request, return_users=1, trivial=trivial)
+    comment = event.comment
+    page = event.page
+    request = event.request
+    trivial = isinstance(event, ev.TrivialPageChangedEvent)
+    subscribers = page.getSubscribers(request, return_users=1)
     mail_from = page.cfg.mail_from
 
     if subscribers:
@@ -86,7 +89,7 @@
         # send email to all subscribers
         for lang in subscribers:
             users = [u for u in subscribers[lang]
-                     if ev.PageChangedEvent.name in u.email_subscribed_events]
+                     if event.name in u.email_subscribed_events]
             emails = [u.email for u in users]
             names = [u.name for u in users]
             data = prep_page_changed_mail(request, page, comment, lang, revisions, trivial)
@@ -165,10 +168,8 @@
     if not event.request.cfg.mail_enabled:
         return
 
-    if isinstance(event, ev.PageChangedEvent):
-        return notify_subscribers(event.request, event.page, event.comment, False)
-    elif isinstance(event, ev.TrivialPageChangedEvent):
-        return notify_subscribers(event.request, event.page, event.comment, True)
+    if isinstance(event, (ev.PageChangedEvent, ev.TrivialPageChangedEvent)):
+        return handle_page_change(event)
     elif isinstance(event, ev.UserCreatedEvent):
         return handle_user_created(event)
     elif isinstance(event, ev.FileAttachedEvent):
--- a/MoinMoin/events/jabbernotify.py	Tue Apr 22 15:54:35 2008 +0200
+++ b/MoinMoin/events/jabbernotify.py	Tue Apr 22 23:00:40 2008 +0200
@@ -28,11 +28,9 @@
     if not cfg.jabber_enabled:
         return
 
-    if isinstance(event, ev.PageChangedEvent):
-        return handle_page_changed(event, False)
-    elif isinstance(event, ev.TrivialPageChangedEvent):
-        return handle_page_changed(event, True)
-    elif isinstance(event, ev.JabberIDSetEvent) or isinstance(event, ev.JabberIDUnsetEvent):
+    if isinstance(event, (ev.PageChangedEvent, ev.TrivialPageChangedEvent)):
+        return handle_page_changed(event)
+    elif isinstance(event, (ev.JabberIDSetEvent, ev.JabberIDUnsetEvent)):
         return handle_jid_changed(event)
     elif isinstance(event, ev.FileAttachedEvent):
         return handle_file_attached(event)
@@ -95,12 +93,12 @@
     return notification.Success(names)
 
 
-def handle_page_changed(event, trivial):
+def handle_page_changed(event):
     """ Handles events related to page changes """
     request = event.request
     page = event.page
 
-    subscribers = page.getSubscribers(request, return_users=1, trivial=trivial)
+    subscribers = page.getSubscribers(request, return_users=1)
     notification.filter_subscriber_list(event, subscribers, True)
     return page_change("page_changed", request, page, subscribers, \
                        revisions=page.getRevList(), comment=event.comment)