comparison roundup/roundupdb.py @ 5675:f3d68c1bb96e

issue2551018 add new nosy_filter parameter to nosymessage. Function passed as nosy_filter can rewrite the nosy message body before it's sent. Tom Ekberg tekberg did the work.
author John Rouillard <rouilj@ieee.org>
date Mon, 25 Mar 2019 19:45:08 -0400
parents b7fa56ced601
children 2c0f89edabe1
comparison
equal deleted inserted replaced
5674:6dc4dba1c225 5675:f3d68c1bb96e
221 appended to the "messages" field of the specified issue. 221 appended to the "messages" field of the specified issue.
222 """ 222 """
223 223
224 def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy', 224 def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
225 from_address=None, cc=[], bcc=[], cc_emails = [], 225 from_address=None, cc=[], bcc=[], cc_emails = [],
226 bcc_emails = [], subject=None ): 226 bcc_emails = [], subject=None,
227 note_filter = None):
227 """Send a message to the members of an issue's nosy list. 228 """Send a message to the members of an issue's nosy list.
228 229
229 The message is sent only to users on the nosy list who are not 230 The message is sent only to users on the nosy list who are not
230 already on the "recipients" list for the message. 231 already on the "recipients" list for the message.
231 232
262 A note on encryption: If pgp encryption for outgoing mails is 263 A note on encryption: If pgp encryption for outgoing mails is
263 turned on in the configuration and no specific pgp roles are 264 turned on in the configuration and no specific pgp roles are
264 defined, we try to send encrypted mail to *all* users 265 defined, we try to send encrypted mail to *all* users
265 *including* cc, bcc, cc_emails and bcc_emails and this might 266 *including* cc, bcc, cc_emails and bcc_emails and this might
266 fail if not all the keys are available in roundups keyring. 267 fail if not all the keys are available in roundups keyring.
268
269 If note_filter is specified it is a function with this
270 prototype:
271 note_filter(original_note, issueid, newvalues, oldvalues)
272 If called, note_filter returns the new value for the message body.
267 """ 273 """
268 encrypt = self.db.config.PGP_ENABLE and self.db.config.PGP_ENCRYPT 274 encrypt = self.db.config.PGP_ENABLE and self.db.config.PGP_ENCRYPT
269 pgproles = self.db.config.PGP_ROLES 275 pgproles = self.db.config.PGP_ROLES
270 if msgid: 276 if msgid:
271 authid = self.db.msg.get(msgid, 'author') 277 authid = self.db.msg.get(msgid, 'author')
343 349
344 if oldvalues: 350 if oldvalues:
345 note = self.generateChangeNote(issueid, oldvalues) 351 note = self.generateChangeNote(issueid, oldvalues)
346 else: 352 else:
347 note = self.generateCreateNote(issueid) 353 note = self.generateCreateNote(issueid)
354 if note_filter:
355 cn = self.classname
356 cl = self.db.classes[cn]
357 note = note_filter(note, issueid, self.db, cl, oldvalues)
348 358
349 # If we have new recipients, update the message's recipients 359 # If we have new recipients, update the message's recipients
350 # and send the mail. 360 # and send the mail.
351 if sendto['plain'] or sendto['crypt']: 361 if sendto['plain'] or sendto['crypt']:
352 # update msgid and recipients only if non-bcc have changed 362 # update msgid and recipients only if non-bcc have changed

Roundup Issue Tracker: http://roundup-tracker.org/