]> git.pld-linux.org Git - packages/cvsspam.git/blame - cvsspam-mail_threading.patch
- wordwrap for css .comment class
[packages/cvsspam.git] / cvsspam-mail_threading.patch
CommitLineData
da83fad6
ER
1Index: cvsspam.rb
2===================================================================
3RCS file: /var/lib/cvs/cvsspam/cvsspam.rb,v
4retrieving revision 1.69
5diff -u -r1.69 cvsspam.rb
6--- cvsspam.rb 13 May 2005 20:06:55 -0000 1.69
7+++ cvsspam.rb 14 May 2005 10:53:33 -0000
8@@ -1235,6 +1235,7 @@
9 $debug = false
10 $recipients = Array.new
11 $sendmail_prog = "/usr/sbin/sendmail"
12+$hostname = ENV['HOSTNAME'] || 'localhost'
13 $no_removed_file_diff = false
14 $no_added_file_diff = false
15 $no_diff = false
16@@ -1748,7 +1749,7 @@
17 from = EmailAddress.new(ENV['USER'] || ENV['USERNAME'] || 'cvsspam')
18 end
19 unless from.address =~ /@/
20- from.address = "#{from.address}@#{ENV['HOSTNAME']||'localhost'}"
21+ from.address = "#{from.address}@#{$hostname}"
22 end
23 smtp = Net::SMTP.new(@smtp_host)
24 blah("connecting to '#{@smtp_host}'")
25@@ -1764,6 +1765,40 @@
26 end
27 end
28
29+
30+def make_msg_id(localpart, hostpart)
31+ "<cvsspam-#{localpart}@#{hostpart}>"
32+end
33+
34+
35+# replaces control characters, and a selection of other characters that
36+# may not appear unquoted in an RFC822 'word', with underscores. (It
37+# doesn't actually zap '.' though.)
38+def zap_header_special_chars(text)
39+ text.gsub(/<>()\[\]@,;:\\[\000-\037\177]/, "_")
40+end
41+
42+
43+# Mail clients will try to 'thread' together a conversation over
44+# several email messages by inspecting the In-Reply-To and References headers,
45+# which should refer to previous emails in the conversation by mentioning
46+# the value of the previous message's Message-Id header. This function invents
47+# values for these headers so that, in the special case where a *single* file
48+# is committed to repeatedly, the emails giving notification of these commits
49+# can be threaded together automatically by the mail client.
50+def inject_threading_headers(mail)
51+ return unless $fileEntries.length == 1
52+ file = $fileEntries[0]
53+ name = zap_header_special_chars(file.path)
54+ unless file.fromVer == "NONE"
55+ mail.header("References", make_msg_id("#{name}.#{file.fromVer}", $hostname))
56+ end
57+ unless file.toVer == "NONE"
58+ mail.header("Message-ID", make_msg_id("#{name}.#{file.toVer}", $hostname))
59+ end
60+end
61+
62+
63 if $smtp_host
64 require 'net/smtp'
65 mailer = SMTPMailer.new($smtp_host)
66@@ -1775,6 +1810,7 @@
67
68 mailer.send($from_address, $recipients) do |mail|
69 mail.header("Subject", mailSubject)
70+ inject_threading_headers(mail)
71 mail.header("MIME-Version", "1.0")
72 mail.header("Content-Type", "text/html" + ($charset.nil? ? "" : "; charset=\"#{$charset}\""))
73 if ENV['REMOTE_HOST']
This page took 0.093892 seconds and 4 git commands to generate.