lib/sup/modes/edit_message_mode.rb in sup-0.18.0 vs lib/sup/modes/edit_message_mode.rb in sup-0.19.0

- old
+ new

@@ -23,10 +23,20 @@ Return value: A string (multi-line ok) containing the text of the signature, or nil to use the default signature, or :none for no signature. EOS + HookManager.register "check-attachment", <<EOS +Do checks on the attachment filename +Variables: + filename: the name of the attachment +Return value: + A String (single line) containing a message why this attachment is not optimal + to be attached. + If it is ok just return an empty string or nil +EOS + HookManager.register "before-edit", <<EOS Modifies message body and headers before editing a new message. Variables should be modified in place. Variables: header: a hash of headers. See 'signature' hook for documentation. @@ -329,9 +339,15 @@ def unsaved?; edited? end def attach_file fn = BufferManager.ask_for_filename :attachment, "File name (enter for browser): " return unless fn + if HookManager.enabled? "check-attachment" + reason = HookManager.run("check-attachment", :filename => fn) + if reason + return unless BufferManager.ask_yes_or_no("#{reason} Attach anyway?") + end + end begin Dir[fn].each do |f| @attachments << RMail::Message.make_file_attachment(f) @attachment_names << f end