]> git.pld-linux.org Git - packages/cvsspam.git/commitdiff
- mail threading feature by author
authorElan Ruusamäe <glen@pld-linux.org>
Sat, 14 May 2005 21:09:54 +0000 (21:09 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    cvsspam-mail_threading.patch -> 1.1

cvsspam-mail_threading.patch [new file with mode: 0644]

diff --git a/cvsspam-mail_threading.patch b/cvsspam-mail_threading.patch
new file mode 100644 (file)
index 0000000..d934c8f
--- /dev/null
@@ -0,0 +1,73 @@
+Index: cvsspam.rb
+===================================================================
+RCS file: /var/lib/cvs/cvsspam/cvsspam.rb,v
+retrieving revision 1.69
+diff -u -r1.69 cvsspam.rb
+--- cvsspam.rb 13 May 2005 20:06:55 -0000      1.69
++++ cvsspam.rb 14 May 2005 10:53:33 -0000
+@@ -1235,6 +1235,7 @@
+ $debug = false
+ $recipients = Array.new
+ $sendmail_prog = "/usr/sbin/sendmail"
++$hostname = ENV['HOSTNAME'] || 'localhost'
+ $no_removed_file_diff = false
+ $no_added_file_diff = false
+ $no_diff = false
+@@ -1748,7 +1749,7 @@
+       from = EmailAddress.new(ENV['USER'] || ENV['USERNAME'] || 'cvsspam')
+     end  
+     unless from.address =~ /@/
+-      from.address = "#{from.address}@#{ENV['HOSTNAME']||'localhost'}"
++      from.address = "#{from.address}@#{$hostname}"
+     end
+     smtp = Net::SMTP.new(@smtp_host)
+     blah("connecting to '#{@smtp_host}'")
+@@ -1764,6 +1765,40 @@
+   end
+ end
++
++def make_msg_id(localpart, hostpart)
++  "<cvsspam-#{localpart}@#{hostpart}>"
++end
++
++
++# replaces control characters, and a selection of other characters that
++# may not appear unquoted in an RFC822 'word', with underscores.  (It
++# doesn't actually zap '.' though.)
++def zap_header_special_chars(text)
++  text.gsub(/<>()\[\]@,;:\\[\000-\037\177]/, "_")
++end
++
++
++# Mail clients will try to 'thread' together a conversation over
++# several email messages by inspecting the In-Reply-To and References headers,
++# which should refer to previous emails in the conversation by mentioning
++# the value of the previous message's Message-Id header.  This function invents
++# values for these headers so that, in the special case where a *single* file
++# is committed to repeatedly, the emails giving notification of these commits
++# can be threaded together automatically by the mail client.
++def inject_threading_headers(mail)
++  return unless $fileEntries.length == 1
++  file = $fileEntries[0]
++  name = zap_header_special_chars(file.path)
++  unless file.fromVer == "NONE"
++    mail.header("References", make_msg_id("#{name}.#{file.fromVer}", $hostname))
++  end
++  unless file.toVer == "NONE"
++    mail.header("Message-ID", make_msg_id("#{name}.#{file.toVer}", $hostname))
++  end
++end
++
++
+ if $smtp_host
+   require 'net/smtp'
+   mailer = SMTPMailer.new($smtp_host)
+@@ -1775,6 +1810,7 @@
+ mailer.send($from_address, $recipients) do |mail|
+   mail.header("Subject", mailSubject)
++  inject_threading_headers(mail)
+   mail.header("MIME-Version", "1.0")
+   mail.header("Content-Type", "text/html" + ($charset.nil? ? "" : "; charset=\"#{$charset}\""))
+   if ENV['REMOTE_HOST']
This page took 0.030865 seconds and 4 git commands to generate.