Attachment 'moin-1.2.3-trivial-notification.patch'
Download 1 # This is a patch for moin-1.2.3.orig to update it to moin-1.2.3
2 #
3 # To apply this patch:
4 # STEP 1: Chdir to the source directory.
5 # STEP 2: Run the 'applypatch' program with this patch file as input.
6 #
7 # If you do not have 'applypatch', it is part of the 'makepatch' package
8 # that you can fetch from the Comprehensive Perl Archive Network:
9 # http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
10 # In the above URL, 'x' should be 2 or higher.
11 #
12 # To apply this patch without the use of 'applypatch':
13 # STEP 1: Chdir to the source directory.
14 # STEP 2: Run the 'patch' program with this file as input.
15 #
16 #### End of Preamble ####
17
18 #### Patch data follows ####
19 diff -u 'moin-1.2.3.orig/MoinMoin/Page.py' 'moin-1.2.3/MoinMoin/Page.py'
20 Index: ./MoinMoin/Page.py
21 --- ./MoinMoin/Page.py Thu Oct 21 16:02:33 2004
22 +++ ./MoinMoin/Page.py Thu Oct 21 16:03:20 2004
23 @@ -333,11 +333,13 @@
24 @param request: the request object
25 @keyword include_self: if 1, include current user (default: 0)
26 @keyword return_users: if 1, return user instances (default: 0)
27 + @keyword trivial: if 1, only include users who want trivial changes (default: 0)
28 @rtype: dict
29 @return: lists of subscribed email addresses in a dict by language key
30 """
31 include_self = kw.get('include_self', 0)
32 return_users = kw.get('return_users', 0)
33 + trivial = kw.get('trivial', 0)
34
35 # extract categories of this page
36 pageList = self.getCategories(request)
37 @@ -353,24 +355,31 @@
38 # get email addresses of the all wiki user which have a profile stored;
39 # add the address only if the user has subscribed to the page and
40 # the user is not the current editor
41 + # Also, if the change is trivial (send email isn't ticked) only send email to users
42 + # who want_trivial changes (typically Admins on public sites)
43 userlist = user.getUserList()
44 - emails = {}
45 + subscriber_list = {}
46 for uid in userlist:
47 if uid == request.user.id and not include_self: continue # no self notification
48 subscriber = user.User(request, uid)
49 - if not subscriber.email: continue # skip empty email address
50 +
51 + # This is a bit wrong if return_users=1 (which implies that the caller will process
52 + # user attributes and may, for example choose to send an SMS)
53 + # So it _should_ be "not (subscriber.email and return_users)" but that breaks at the moment.
54 + if not subscriber.email: continue # skip empty email addresses
55 + if trivial and not subscriber.want_trivial: continue # skip uninterested subscribers
56
57 if not UserPerms(subscriber).read(self.page_name): continue
58
59 - if subscriber.isSubscribedTo(pageList):
60 + if subscriber.isSubscribedTo(pageList):
61 lang = subscriber.language or 'en'
62 - if not emails.has_key(lang): emails[lang] = []
63 + if not subscriber_list.has_key(lang): subscriber_list[lang] = []
64 if return_users:
65 - emails[lang].append(subscriber)
66 + subscriber_list[lang].append(subscriber)
67 else:
68 - emails[lang].append(subscriber.email)
69 + subscriber_list[lang].append(subscriber.email)
70
71 - return emails
72 + return subscriber_list
73
74
75 def send_page(self, request, msg=None, **keywords):
76 diff -u 'moin-1.2.3.orig/MoinMoin/PageEditor.py' 'moin-1.2.3/MoinMoin/PageEditor.py'
77 Index: ./MoinMoin/PageEditor.py
78 --- ./MoinMoin/PageEditor.py Thu Oct 21 16:02:33 2004
79 +++ ./MoinMoin/PageEditor.py Thu Oct 21 16:03:20 2004
80 @@ -463,13 +463,14 @@
81 cache.remove()
82
83
84 - def _sendNotification(self, comment, emails, email_lang, oldversions):
85 + def _sendNotification(self, comment, emails, email_lang, oldversions, trivial):
86 """
87 Send notification email for a single language.
88 @param comment: editor's comment given when saving the page
89 @param emails: list of email addresses
90 @param email_lang: language of emails
91 @param oldversions: old versions of this page
92 + @param trivial: the change is marked as trivial
93 @rtype: int
94 @return: sendmail result
95 """
96 @@ -491,7 +492,8 @@
97 # append a diff
98 if not oldversions:
99 mailBody = mailBody + \
100 - _("No older revisions of the page stored, diff not available.")
101 + _("New page:\n") + \
102 + Page(self.page_name).get_raw_body()
103 else:
104 newpage = os.path.join(config.text_dir, wikiutil.quoteFilename(self.page_name))
105 oldpage = os.path.join(config.backup_dir, oldversions[0])
106 @@ -507,7 +509,8 @@
107 _('The diff function returned with error code %(rc)s!') % {'rc': rc}
108
109 return util.mail.sendmail(self.request, emails,
110 - _('[%(sitename)s] Update of "%(pagename)s"') % {
111 + _('[%(sitename)s]%(trivial)s Update of "%(pagename)s"') % {
112 + 'trivial' : (trivial or "") and " Trivial",
113 'sitename': config.sitename or "Wiki",
114 'pagename': self.page_name,
115 },
116 @@ -515,16 +518,17 @@
117 # was: self.request.user.email, but we don't want to disclose email
118
119
120 - def _notifySubscribers(self, comment):
121 + def _notifySubscribers(self, comment, trivial):
122 """
123 Send email to all subscribers of this page.
124
125 @param comment: editor's comment given when saving the page
126 + @param trivial: editor's suggestion that the change is trivial (Subscribers may ignore this)
127 @rtype: string
128 @return: message, indicating success or errors.
129 """
130 _ = self._
131 - subscribers = self.getSubscribers(self.request, return_users=1)
132 + subscribers = self.getSubscribers(self.request, return_users=1, trivial=trivial)
133
134 wiki_is_smarter_than_its_users = _("You will not be notified of your own changes!") + '<br>'
135
136 @@ -537,11 +541,18 @@
137 for lang in subscribers.keys():
138 emails = map(lambda u: u.email, subscribers[lang])
139 names = map(lambda u: u.name, subscribers[lang])
140 - mailok, status = self._sendNotification(comment, emails, lang, oldversions)
141 + mailok, status = self._sendNotification(comment, emails, lang, oldversions, trivial)
142 recipients = ", ".join(names)
143 results.append(_('[%(lang)s] %(recipients)s: %(status)s') % {
144 'lang': lang, 'recipients': recipients, 'status': status})
145
146 + if trivial:
147 + # lie about not sending email (so abusers think their actions are hidden)
148 + # This is a bit inconsistent with having this as a user option - maybe reconsider u.want_trivia
149 + # to be memberOfGroup(WantTrivia)
150 + # FIXME also maybe make this a wiki configurable?
151 + return _('')
152 +
153 return wiki_is_smarter_than_its_users + '<br>'.join(results)
154
155 return wiki_is_smarter_than_its_users + _('Nobody subscribed to this page, no mail sent.')
156 @@ -792,8 +803,8 @@
157 {'pagename': self.page_name})
158
159 # send notification mails
160 - if config.mail_smarthost and kw.get('notify', 0):
161 - msg = msg + self._notifySubscribers(kw.get('comment', ''))
162 + if config.mail_smarthost:
163 + msg = msg + self._notifySubscribers(kw.get('comment', ''), not kw.get('notify', 0))
164
165 # remove lock (forcibly if we were allowed to break it by the UI)
166 # !!! this is a little fishy, since the lock owner might not notice
167 diff -u 'moin-1.2.3.orig/MoinMoin/user.py' 'moin-1.2.3/MoinMoin/user.py'
168 Index: ./MoinMoin/user.py
169 --- ./MoinMoin/user.py Wed Jul 21 21:02:16 2004
170 +++ ./MoinMoin/user.py Thu Oct 21 16:03:20 2004
171 @@ -110,6 +110,7 @@
172 ('show_fancy_diff', lambda _: _('Show fancy diffs')),
173 ('wikiname_add_spaces', lambda _: _('Add spaces to displayed wiki names')),
174 ('remember_me', lambda _: _('Remember login information forever')),
175 + ('want_trivial', lambda _: _('Subscribe to trivial changes')),
176 ('disabled', lambda _: _('Disable this account forever')),
177 ]
178 _transient_fields = ['id', 'valid', 'may', 'auth_username', 'trusted']
179 @@ -173,6 +174,7 @@
180 self.show_toolbar = 1
181 self.show_nonexist_qm = config.nonexist_qm
182 self.show_fancy_diff = 1
183 + self.want_trivial = 0
184 self.remember_me = 1
185
186 if not self.id and not self.auth_username:
187 #### End of Patch data ####
188
189 #### ApplyPatch data follows ####
190 # Data version : 1.0
191 # Date generated : Thu Oct 21 16:04:05 2004
192 # Generated by : makepatch 2.00_07*
193 # Recurse directories : Yes
194 # Excluded files : (\A|/).*\~\Z
195 # (\A|/).*\.a\Z
196 # (\A|/).*\.bak\Z
197 # (\A|/).*\.BAK\Z
198 # (\A|/).*\.elc\Z
199 # (\A|/).*\.exe\Z
200 # (\A|/).*\.gz\Z
201 # (\A|/).*\.ln\Z
202 # (\A|/).*\.o\Z
203 # (\A|/).*\.obj\Z
204 # (\A|/).*\.olb\Z
205 # (\A|/).*\.old\Z
206 # (\A|/).*\.orig\Z
207 # (\A|/).*\.rej\Z
208 # (\A|/).*\.so\Z
209 # (\A|/).*\.Z\Z
210 # (\A|/)\.del\-.*\Z
211 # (\A|/)\.make\.state\Z
212 # (\A|/)\.nse_depinfo\Z
213 # (\A|/)core\Z
214 # (\A|/)tags\Z
215 # (\A|/)TAGS\Z
216 # (\A|/)\.\#.*\Z
217 # (\A|/)\#.*\Z
218 # (\A|/)_\$.*\Z
219 # (\A|/).*\$\Z
220 # (\A|/)CVS\Z
221 # (\A|/)CVS\.adm\Z
222 # (\A|/)cvslog\..*\Z
223 # (\A|/)\,.*\Z
224 # (\A|/).*\,v\Z
225 # (\A|/)RCS\Z
226 # (\A|/)RCSLOG\Z
227 # (\A|/)p\..*\Z
228 # (\A|/)s\..*\Z
229 # (\A|/)SCCS\Z
230 # p 'MoinMoin/Page.py' 33174 1098371000 0100644
231 # p 'MoinMoin/PageEditor.py' 38314 1098371000 0100644
232 # p 'MoinMoin/user.py' 20137 1098371000 0100644
233 #### End of ApplyPatch data ####
234
235 #### End of Patch kit [created: Thu Oct 21 16:04:05 2004] ####
236 #### Patch checksum: 218 10007 2187 ####
237 #### Checksum: 236 10694 58896 ####
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.