whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: WHIMSY-213 Allow for 2-line message-ID
Date Thu, 25 Oct 2018 22:44:05 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 4f26252  WHIMSY-213 Allow for 2-line message-ID
4f26252 is described below

commit 4f26252ae5493fd65b3fa14c56c62c863db9d3cf
Author: Sebb <sebb@apache.org>
AuthorDate: Thu Oct 25 23:43:55 2018 +0100

    WHIMSY-213 Allow for 2-line message-ID
    
    Also fix other delivery agent
---
 tools/deliver.rb | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/deliver.rb b/tools/deliver.rb
index e78f144..a213e25 100644
--- a/tools/deliver.rb
+++ b/tools/deliver.rb
@@ -8,12 +8,22 @@ require 'fileutils'
 
 MAIL_ROOT = '/srv/mail'
 
+# get the message ID
+def self.getmid(hdrs)
+  mid = hdrs[/^Message-ID:.*/i]
+  if mid =~ /^Message-ID:\s*$/i # no mid on the first line
+    # capture the next line and join them together
+    mid = hdrs[/^Message-ID:.*\r?\n .*/i].sub(/\r?\n/,'')
+  end
+  mid
+end
+
 mail = STDIN.read.force_encoding('binary')
 
 # extract info
 dest = mail[/^List-Id: <(.*)>/, 1] || mail[/^Delivered-To.* (\S+)\s*$/, 1] || 'unknown'
 time = Time.parse(mail[/^Date: (.*)/, 1]) rescue Time.now
-hash = Digest::SHA1.hexdigest(mail[/^Message-ID:.*/i] || mail)[0..9]
+hash = Digest::SHA1.hexdigest(getmid(mail) || mail)[0..9]
 
 # build file name
 file = "#{MAIL_ROOT}/#{dest[/^[-\w]+/]}/#{time.strftime("%Y%m")}/#{hash}"
@@ -23,3 +33,4 @@ FileUtils.mkdir_p File.dirname(file)
 File.write file, mail, encoding: Encoding::BINARY
 File.utime time, time, file
 File.chmod 0644, file
+puts file
\ No newline at end of file


Mime
View raw message