From 9e3f1ee0a8dc59119a973a694587e54e5a9dda9d Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 8 Apr 2002 03:40:31 +0000 Subject: [PATCH] . added a "detectors" directory for people to put their useful auditors and reactors in. Note - the roundupdb.IssueClass.sendmessage method has been split and renamed "nosymessage" specifically for things like the nosy reactor, and "send_message" which just sends the message. The initial detector is one that we'll be using here at ekit - it bounces new issue messages to a team address. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@697 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 4 ++++ detectors/newissuecopy.py | 20 ++++++++++++++++++++ doc/customizing.txt | 13 +++++++++++++ roundup/roundupdb.py | 39 +++++++++++++++++++++++++++++---------- 4 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 detectors/newissuecopy.py diff --git a/CHANGES.txt b/CHANGES.txt index fe640b1..de2c49d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,10 @@ are given with the most recent entry first. 2002-04-?? 0.4.2 Feature: + . added a "detectors" directory for people to put their useful auditors and + reactors in. Note - the roundupdb.IssueClass.sendmessage method has been + split and renamed "nosymessage" specifically for things like the nosy + reactor, and "send_message" which just sends the message. . link() htmltemplate function now has a "showid" option for links and multilinks. When true, it only displays the linked node id as the anchor text. The link value is displayed as a tooltip using the title anchor diff --git a/detectors/newissuecopy.py b/detectors/newissuecopy.py new file mode 100644 index 0000000..7bcb6de --- /dev/null +++ b/detectors/newissuecopy.py @@ -0,0 +1,20 @@ +# copied from nosyreaction + +from roundup import roundupdb + +def newissuecopy(db, cl, nodeid, oldvalues): + ''' Copy a message about new issues to a team address. + ''' + # so use all the messages in the create + change_note = cl.generateCreateNote(nodeid) + + # send a copy to the nosy list + for msgid in cl.get(nodeid, 'messages'): + try: + cl.send_message(nodeid, msgid, change_note, 'team@team.host') + except roundupdb.MessageSendError, message: + raise roundupdb.DetectorError, message + +def init(db): + db.issue.react('create', newissuecopy) + diff --git a/doc/customizing.txt b/doc/customizing.txt index cf9f18a..b2c9729 100644 --- a/doc/customizing.txt +++ b/doc/customizing.txt @@ -242,6 +242,19 @@ create(information) Create a node in the database. This is generally used to create nodes in the "definitional" classes like "priority" and "status". + +Detectors - adding behaviour to your tracker +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sample additional detectors that have been found useful will appear in the +``detectors`` directory of the Roundup distribution: + +newissuecopy.py + This detector sends an email to a team address whenever a new issue is + created. The address is hard-coded into the detector, so edit it before you + use it (look for the text 'team@team.host') or you'll get email errors! + + Web Interface ------------- diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index 68a97e3..c9d2912 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.49 2002-03-19 06:41:49 richard Exp $ +# $Id: roundupdb.py,v 1.50 2002-04-08 03:40:31 richard Exp $ __doc__ = """ Extending hyperdb with types specific to issue-tracking. @@ -297,7 +297,7 @@ class IssueClass(Class): appended to the "messages" field of the specified issue. """ - def sendmessage(self, nodeid, msgid, change_note): + def nosymessage(self, nodeid, msgid, change_note): """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 @@ -307,7 +307,6 @@ class IssueClass(Class): """ users = self.db.user messages = self.db.msg - files = self.db.file # figure the recipient ids sendto = [] @@ -342,13 +341,30 @@ class IssueClass(Class): sendto.append(nosyid) recipients.append(nosyid) - # no new recipients - if not sendto: - return + # we have new recipients + if sendto: + # update the message's recipients list + messages.set(msgid, recipients=recipients) + + # send the message + self.send_message(nodeid, msgid, change_note, sendto) + + # XXX backwards compatibility - don't remove + sendmessage = nosymessage + + def send_message(self, nodeid, msgid, note, sendto): + '''Actually send the nominated message from this node to the sendto + recipients, with the note appended. + ''' + users = self.db.user + messages = self.db.msg + files = self.db.file # determine the messageid and inreplyto of the message inreplyto = messages.get(msgid, 'inreplyto') messageid = messages.get(msgid, 'messageid') + + # make up a messageid if there isn't one (web edit) if not messageid: # this is an old message that didn't get a messageid, so # create one @@ -356,8 +372,8 @@ class IssueClass(Class): self.classname, nodeid, self.db.config.MAIL_DOMAIN) messages.set(msgid, messageid=messageid) - # update the message's recipients list - messages.set(msgid, recipients=recipients) + # figure the author's id + authid = messages.get(msgid, 'author') # send an email to the people who missed out sendto = [users.get(i, 'address') for i in sendto] @@ -391,8 +407,8 @@ class IssueClass(Class): m.append(messages.get(msgid, 'content')) # add the change note - if change_note: - m.append(change_note) + if note: + m.append(note) # put in roundup's signature if self.db.config.EMAIL_SIGNATURE_POSITION == 'bottom': @@ -604,6 +620,9 @@ class IssueClass(Class): # # $Log: not supported by cvs2svn $ +# Revision 1.49 2002/03/19 06:41:49 richard +# Faster, easier, less mess ;) +# # Revision 1.48 2002/03/18 18:32:00 rochecompaan # All messages sent to the nosy list are now encoded as quoted-printable. # -- 2.30.2