changeset 684:5b23ff865f3a

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.
author Richard Jones <richard@users.sourceforge.net>
date Mon, 08 Apr 2002 03:40:31 +0000
parents 5a4dd342d827
children de6dc74a4148
files CHANGES.txt detectors/newissuecopy.py doc/customizing.txt roundup/roundupdb.py
diffstat 4 files changed, 66 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Wed Apr 03 07:05:50 2002 +0000
+++ b/CHANGES.txt	Mon Apr 08 03:40:31 2002 +0000
@@ -3,6 +3,10 @@
 
 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/detectors/newissuecopy.py	Mon Apr 08 03:40:31 2002 +0000
@@ -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)
+
--- a/doc/customizing.txt	Wed Apr 03 07:05:50 2002 +0000
+++ b/doc/customizing.txt	Mon Apr 08 03:40:31 2002 +0000
@@ -242,6 +242,19 @@
 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
 -------------
 
--- a/roundup/roundupdb.py	Wed Apr 03 07:05:50 2002 +0000
+++ b/roundup/roundupdb.py	Mon Apr 08 03:40:31 2002 +0000
@@ -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 @@
         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 @@
         """
         users = self.db.user
         messages = self.db.msg
-        files = self.db.file
 
         # figure the recipient ids
         sendto = []
@@ -342,13 +341,30 @@
                 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 @@
                 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 @@
         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 @@
 
 #
 # $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.
 #

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