Skip to content

Commit 7d5d314

Browse files
author
Richard Jones
committed
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.
1 parent e6ca1e6 commit 7d5d314

File tree

4 files changed

+66
-10
lines changed

4 files changed

+66
-10
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ are given with the most recent entry first.
33

44
2002-04-?? 0.4.2
55
Feature:
6+
. added a "detectors" directory for people to put their useful auditors and
7+
reactors in. Note - the roundupdb.IssueClass.sendmessage method has been
8+
split and renamed "nosymessage" specifically for things like the nosy
9+
reactor, and "send_message" which just sends the message.
610
. link() htmltemplate function now has a "showid" option for links and
711
multilinks. When true, it only displays the linked node id as the anchor
812
text. The link value is displayed as a tooltip using the title anchor

detectors/newissuecopy.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# copied from nosyreaction
2+
3+
from roundup import roundupdb
4+
5+
def newissuecopy(db, cl, nodeid, oldvalues):
6+
''' Copy a message about new issues to a team address.
7+
'''
8+
# so use all the messages in the create
9+
change_note = cl.generateCreateNote(nodeid)
10+
11+
# send a copy to the nosy list
12+
for msgid in cl.get(nodeid, 'messages'):
13+
try:
14+
cl.send_message(nodeid, msgid, change_note, '[email protected]')
15+
except roundupdb.MessageSendError, message:
16+
raise roundupdb.DetectorError, message
17+
18+
def init(db):
19+
db.issue.react('create', newissuecopy)
20+

doc/customizing.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,19 @@ create(information)
242242
Create a node in the database. This is generally used to create nodes in the
243243
"definitional" classes like "priority" and "status".
244244

245+
246+
Detectors - adding behaviour to your tracker
247+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248+
249+
Sample additional detectors that have been found useful will appear in the
250+
``detectors`` directory of the Roundup distribution:
251+
252+
newissuecopy.py
253+
This detector sends an email to a team address whenever a new issue is
254+
created. The address is hard-coded into the detector, so edit it before you
255+
use it (look for the text '[email protected]') or you'll get email errors!
256+
257+
245258
Web Interface
246259
-------------
247260

roundup/roundupdb.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.49 2002-03-19 06:41:49 richard Exp $
18+
# $Id: roundupdb.py,v 1.50 2002-04-08 03:40:31 richard Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
@@ -297,7 +297,7 @@ def addmessage(self, nodeid, summary, text):
297297
appended to the "messages" field of the specified issue.
298298
"""
299299

300-
def sendmessage(self, nodeid, msgid, change_note):
300+
def nosymessage(self, nodeid, msgid, change_note):
301301
"""Send a message to the members of an issue's nosy list.
302302
303303
The message is sent only to users on the nosy list who are not
@@ -307,7 +307,6 @@ def sendmessage(self, nodeid, msgid, change_note):
307307
"""
308308
users = self.db.user
309309
messages = self.db.msg
310-
files = self.db.file
311310

312311
# figure the recipient ids
313312
sendto = []
@@ -342,22 +341,39 @@ def sendmessage(self, nodeid, msgid, change_note):
342341
sendto.append(nosyid)
343342
recipients.append(nosyid)
344343

345-
# no new recipients
346-
if not sendto:
347-
return
344+
# we have new recipients
345+
if sendto:
346+
# update the message's recipients list
347+
messages.set(msgid, recipients=recipients)
348+
349+
# send the message
350+
self.send_message(nodeid, msgid, change_note, sendto)
351+
352+
# XXX backwards compatibility - don't remove
353+
sendmessage = nosymessage
354+
355+
def send_message(self, nodeid, msgid, note, sendto):
356+
'''Actually send the nominated message from this node to the sendto
357+
recipients, with the note appended.
358+
'''
359+
users = self.db.user
360+
messages = self.db.msg
361+
files = self.db.file
348362

349363
# determine the messageid and inreplyto of the message
350364
inreplyto = messages.get(msgid, 'inreplyto')
351365
messageid = messages.get(msgid, 'messageid')
366+
367+
# make up a messageid if there isn't one (web edit)
352368
if not messageid:
353369
# this is an old message that didn't get a messageid, so
354370
# create one
355371
messageid = "<%s.%s.%s%s@%s>"%(time.time(), random.random(),
356372
self.classname, nodeid, self.db.config.MAIL_DOMAIN)
357373
messages.set(msgid, messageid=messageid)
358374

359-
# update the message's recipients list
360-
messages.set(msgid, recipients=recipients)
375+
# figure the author's id
376+
authid = messages.get(msgid, 'author')
361377

362378
# send an email to the people who missed out
363379
sendto = [users.get(i, 'address') for i in sendto]
@@ -391,8 +407,8 @@ def sendmessage(self, nodeid, msgid, change_note):
391407
m.append(messages.get(msgid, 'content'))
392408

393409
# add the change note
394-
if change_note:
395-
m.append(change_note)
410+
if note:
411+
m.append(note)
396412

397413
# put in roundup's signature
398414
if self.db.config.EMAIL_SIGNATURE_POSITION == 'bottom':
@@ -604,6 +620,9 @@ def generateChangeNote(self, nodeid, oldvalues):
604620

605621
#
606622
# $Log: not supported by cvs2svn $
623+
# Revision 1.49 2002/03/19 06:41:49 richard
624+
# Faster, easier, less mess ;)
625+
#
607626
# Revision 1.48 2002/03/18 18:32:00 rochecompaan
608627
# All messages sent to the nosy list are now encoded as quoted-printable.
609628
#

0 commit comments

Comments
 (0)