diff 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
line wrap: on
line diff
--- a/roundup/roundupdb.py	Mon Mar 25 21:23:52 2019 +0100
+++ b/roundup/roundupdb.py	Mon Mar 25 19:45:08 2019 -0400
@@ -223,7 +223,8 @@
 
     def nosymessage(self, issueid, msgid, oldvalues, whichnosy='nosy',
             from_address=None, cc=[], bcc=[], cc_emails = [],
-            bcc_emails = [], subject=None ):
+            bcc_emails = [], subject=None,
+            note_filter = None):
         """Send a message to the members of an issue's nosy list.
 
         The message is sent only to users on the nosy list who are not
@@ -264,6 +265,11 @@
         defined, we try to send encrypted mail to *all* users
         *including* cc, bcc, cc_emails and bcc_emails and this might
         fail if not all the keys are available in roundups keyring.
+
+        If note_filter is specified it is a function with this
+        prototype:
+            note_filter(original_note, issueid, newvalues, oldvalues)
+        If called, note_filter returns the new value for the message body.
         """
         encrypt = self.db.config.PGP_ENABLE and self.db.config.PGP_ENCRYPT
         pgproles = self.db.config.PGP_ROLES
@@ -345,6 +351,10 @@
             note = self.generateChangeNote(issueid, oldvalues)
         else:
             note = self.generateCreateNote(issueid)
+        if note_filter:
+            cn = self.classname
+            cl = self.db.classes[cn]
+            note = note_filter(note, issueid, self.db, cl, oldvalues)
 
         # If we have new recipients, update the message's recipients
         # and send the mail.

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