-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Message#without_attachments! to delete attachments recursively #858
Conversation
8357392
to
eee42c4
Compare
91295fc
to
305072f
Compare
Nice implementation. But why? What motivates this change? |
Is there something blocking this pull request? I am especially interested in If there is something specific to be done I'd love to help. |
Here is a small module I've been using as a workaround. I'll be very happy to submit something similar as a PR. module MailHelper
module_function
def delete_parts_if(mail, &block)
removed_parts = []
mail.parts.each do |part|
if yield(part)
mail.parts.delete(part)
removed_parts << part
end
if part.mime_type == 'message/rfc822'
sub_mail, sub_removed_parts = delete_parts_if(Mail.new(part.decoded), &block)
part.body = sub_mail.encoded
removed_parts += sub_removed_parts
end
end
[mail, removed_parts]
end
def delete_attachment_parts(mail)
delete_parts_if(mail, &:attachment?)
end
end |
…, no matter how deeply they are nested. Now it is consistent with #attachments, which returns a list of attachments no matter how deeply they are nested. It was only deleting attachments from the top level (parts) but not those in parts[0].parts, for example.
305072f
to
e0ab0b3
Compare
@jeremy I've rebased this PR. Let me know if there's anything else I can do to get it merged. |
Hello, I'm hoping to use the Any suggestions for parsing those emails? I'm thinking I'll just monkey-patch that method onto |
No description provided.