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 a13646d2 Allow for old-style yaml with deleted attachments
a13646d2 is described below
commit a13646d2ff740dc1362fc57a86592d7c0754ed79
Author: Sebb <[email protected]>
AuthorDate: Thu Oct 3 11:24:46 2024 +0100
Allow for old-style yaml with deleted attachments
---
www/secretary/workbench/models/mailbox.rb | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/www/secretary/workbench/models/mailbox.rb
b/www/secretary/workbench/models/mailbox.rb
index 593e7848..a51824e8 100644
--- a/www/secretary/workbench/models/mailbox.rb
+++ b/www/secretary/workbench/models/mailbox.rb
@@ -184,12 +184,21 @@ class Mailbox
#
# return headers (client view; only shows messages with attachments)
- # If :listall is true, then include all entries with an attachments key
+ # If :listall is true, then include all entries with an attachments key
(even if empty)
# (these are messages that originally had attachments)
def client_headers(listall: false)
- # fetch a list of headers for all messages in the mailbox with attachments
- headers = self.headers.to_a.reject do |_id, message|
- Message.attachments(message, includeDeleted: listall).empty?
+ if listall
+ # get all headers which ever had attachments
+ headers = self.headers.to_a.reject do |_id, message|
+ message[:attachments].nil?
+ end
+ else
+ # want all active headers
+ headers = self.headers.to_a.reject do |_id, message|
+ # This does not return attachments with status :deleted
+ # also drops irrelevant attachments
+ Message.attachments(message).empty?
+ end
end
# extract relevant fields from the headers