whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [1/1] Commit 2bd4737: subdivide mail into folders
Date Mon, 22 Feb 2016 18:10:31 GMT
Commit 2bd4737b30d2aeb0ef0eb363c3b244c4b482023c:
    subdivide mail into folders


Branch: refs/heads/master
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
tools/deliver.rb                                             | ++++++++++++ 
www/secmail/config.rb                                        | + -
------------------------------------------------------------
25 changes: 24 additions, 1 deletions.
------------------------------------------------------------


diff --git a/tools/deliver.rb b/tools/deliver.rb
new file mode 100644
index 0000000..a2987bd
--- /dev/null
+++ b/tools/deliver.rb
@@ -0,0 +1,23 @@
+#
+# Receive and deliver mail
+#
+
+require 'digest'
+require 'time'
+require 'fileutils'
+
+MAIL_ROOT = '/srv/mail'
+
+mail = STDIN.read
+
+# extract info
+dest = mail[/List-Id: <(.*)>/, 1] || mail[/Delivered-To.* (\S+)\s*$/, 1]
+time = Time.parse(mail[/^Date: (.*)/, 1]) rescue Time.now
+hash = Digest::SHA1.hexdigest(mail[/^Message-ID:.*/i] || mail)[0..9]
+
+# build file name
+file = "#{MAIL_ROOT}/#{dest[/^[-\w]+/]}/#{time.strftime("%Y%m")}/#{hash}"
+
+FileUtils.mkdir_p File.dirname(file)
+File.write file, mail, encoding: Encoding::BINARY
+File.utime time, time, file
diff --git a/www/secmail/config.rb b/www/secmail/config.rb
index 98b9389..b433b82 100644
--- a/www/secmail/config.rb
+++ b/www/secmail/config.rb
@@ -4,7 +4,7 @@
 
 if Dir.exist? '/srv/mail'
   SOURCE = 'whimsy-vm2.apache.org:/srv/mail'
-  ARCHIVE = '/srv/mail'
+  ARCHIVE = '/srv/mail/secretary'
 else
   SOURCE = 'minotaur.apache.org:/home/apmail/private-arch/officers-secretary'
   ARCHIVE = File.basename(SOURCE)

Mime
View raw message