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 d566f4a9 Add mail properties to ICLA files
d566f4a9 is described below
commit d566f4a998d944c38c1ed6662830c8c71683d75d
Author: Sebb <[email protected]>
AuthorDate: Thu Sep 12 15:34:46 2024 +0100
Add mail properties to ICLA files
---
www/secretary/workbench/models/message.rb | 22 +++++++++++++++++-----
www/secretary/workbench/tasks.rb | 15 +++++++++++++++
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/www/secretary/workbench/models/message.rb
b/www/secretary/workbench/models/message.rb
index 1e23ef5a..d2adb211 100644
--- a/www/secretary/workbench/models/message.rb
+++ b/www/secretary/workbench/models/message.rb
@@ -17,6 +17,9 @@ class Message
# The name used to represent the raw message as an attachment
RAWMESSAGE_ATTACHMENT_NAME = 'rawmessage.txt'
+ # default SVN property names to add to documents
+ PROPNAMES_DEFAULT = %w{email:addr email:id email:name email:subject
envelope:from envelope:date}
+
#
# create a new message
#
@@ -178,11 +181,10 @@ class Message
File.write File.join(dir, @hash), @raw, encoding: Encoding::BINARY
end
- # don't let a problem with the properties stop the commit
- # handle each property separately
- def propset(pathname, propname)
+ def propval(propname)
propval = nil
- case propname
+ begin
+ case propname
when 'email:addr'
propval = from.addrs.first.address
when 'email:id'
@@ -197,7 +199,17 @@ class Message
propval = @headers[:envelope_date]
else
Wunderbar.warn "Don't know propname #{propname}"
+ end
+ rescue StandardError => e
+ Wunderbar.warn "Problem occurred fetching #{propname} #{e}"
end
+ propval
+ end
+
+ # don't let a problem with the properties stop the commit
+ # handle each property separately
+ def propset(pathname, propname)
+ propval = propval(propname)
if propval
begin
system 'svn', 'propset', propname, propval, pathname
@@ -209,7 +221,7 @@ class Message
# Add some properties from the email
def add_email_details(pathname)
- %w{email:addr email:id email:name email:subject envelope:from
envelope:date}.each do |propname|
+ PROPNAMES_DEFAULT.each do |propname|
propset(pathname, propname)
end
end
diff --git a/www/secretary/workbench/tasks.rb b/www/secretary/workbench/tasks.rb
index 32458592..00bb313d 100644
--- a/www/secretary/workbench/tasks.rb
+++ b/www/secretary/workbench/tasks.rb
@@ -65,6 +65,15 @@ class Wunderbar::JsonBuilder
ASF::SVN.svn_!(command, path, _, options)
end
+ def _extra_props(extras, emessage, outpath)
+ Message::PROPNAMES_DEFAULT.each do |propname|
+ propval = emessage.propval(propname)
+ if propval
+ extras << ['propset', propname, propval, outpath]
+ end
+ end
+end
+
# Commit new file(s) and update associated index
# e.g. add ccla.pdf, ccla.pdf.asc to documents/cclas/xyz/ and update
officers/cclas.txt
# Parameters:
@@ -109,6 +118,9 @@ class Wunderbar::JsonBuilder
# N.B. file cannot exist here, because the directory was created as
part of the same commit
extras << ['put', file, outpath]
extras << ['propset', 'svn:mime-type', content_type, outpath]
+ if index_name == 'iclas.txt' # Don't apply this to other types
+ _extra_props(extras, emessage, outpath)
+ end
end
else
_name, file, content_type = dest.flatten
@@ -119,6 +131,9 @@ class Wunderbar::JsonBuilder
else
extras << ['put', file, outpath]
extras << ['propset', 'svn:mime-type', content_type, outpath]
+ if index_name == 'iclas.txt' # Don't apply this to other types
+ _extra_props(extras, emessage, outpath)
+ end
end
end