]> git.cworth.org Git - sup/commitdiff
Bounce Message Hook
authorBen Walton <bwalton@artsci.utoronto.ca>
Sun, 7 Jun 2009 23:44:37 +0000 (19:44 -0400)
committerBen Walton <bwalton@artsci.utoronto.ca>
Sun, 7 Jun 2009 23:44:37 +0000 (19:44 -0400)
Determine the command used to bounce a message based on a Hook instead
of a configuration option.  Instead of writing an external script that
can send the message properly based on the recipient addresses, rely
on a hook that can return the command based on the From header in the
mail being bounced as well as the intended recipients.  This is more
in line with the sup philosophy.

The default is still to strip any -t from the sendmail command of the
default account.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
lib/sup.rb
lib/sup/modes/thread-view-mode.rb

index 76444c95d0168860303c488c19d17512c5920895..96510b2e2d7419629a0a3fd3e9d96eafca29c36e 100644 (file)
@@ -207,7 +207,6 @@ else
     :confirm_top_posting => true,
     :discard_snippets_from_encrypted_messages => false,
     :default_attachment_save_dir => "",
-    :bounce_sendmail => "",
   }
   begin
     FileUtils.mkdir_p Redwood::BASE_DIR
index 8842e59abf479be4de6ceef388770a23ad56563a..76a1d1e9113030ea701e1d59cb0a7c58172dc567 100644 (file)
@@ -24,6 +24,18 @@ Return value:
   None. The variable 'headers' should be modified in place.
 EOS
 
+  HookManager.register "bounce-command", <<EOS
+Determines the command used to bounce a message.
+Variables:
+      from: The From header of the message being bounced
+            (eg: likely _not_ your address).
+        to: The addresses you asked the message to be bounced to as an array.
+Return value:
+  A string representing the command to pipe the mail into.  This
+  should include the entire command except for the destination addresses,
+  which will be appended by sup.
+EOS
+
   register_keymap do |k|
     k.add :toggle_detailed_header, "Toggle detailed header", 'h'
     k.add :show_header, "Show full message header", 'H'
@@ -184,9 +196,9 @@ EOS
       end
     end
 
-    cmd = case $config[:bounce_sendmail]
+    cmd = case HookManager.run "bounce-command", :from => m.from, :to => to
           when nil, /^$/ then defcmd
-          else $config[:bounce_sendmail]
+          else hookcmd
           end + ' ' + to.map { |t| t.email }.join(' ')
 
     bt = to.size > 1 ? "#{to.size} recipients" : to.to_s