whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: try harder to extract mail text
Date Sun, 16 Jun 2019 13:25:55 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys 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 eb74465  try harder to extract mail text
eb74465 is described below

commit eb744654e227056a47c5817bd2bf2fa0d6f007aa
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Sun Jun 16 09:25:39 2019 -0400

    try harder to extract mail text
---
 www/board/agenda/views/actions/posted-reports.json.rb | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/www/board/agenda/views/actions/posted-reports.json.rb b/www/board/agenda/views/actions/posted-reports.json.rb
index 3a9b866..2a5896b 100755
--- a/www/board/agenda/views/actions/posted-reports.json.rb
+++ b/www/board/agenda/views/actions/posted-reports.json.rb
@@ -13,18 +13,23 @@ ARCHIVE = '/srv/mail/board'
 
 if @path and @path =~ /^\d+\/\w+$/
   mail = Mail.new(File.read(File.join(ARCHIVE, @path)))
+  text = ''
+
   if mail.text_part
     begin
       text = mail.text_part.body.to_s.force_encoding(mail.text_part.charset)
     rescue
       text = mail.text_part.body.to_s.force_encoding(Encoding::UTF_8)
     end
-      
-    return {text: text.encode('UTF-8', invalid: :replace, undef: :replace)}
-
-  else
-    return {text: ''}
+  elsif mail.main_type.include? 'text'
+    begin
+      text = mail.body.to_s.force_encoding(mail.text_part.charset)
+    rescue
+      text = mail.body.to_s.force_encoding(Encoding::UTF_8)
+    end
   end
+
+  return {text: text.encode('UTF-8', invalid: :replace, undef: :replace)}
 end
 
 # only look at this month's and last month's mailboxes, and within those


Mime
View raw message