Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: bwalton@artsci.utoronto.ca (Ben Walton)
Subject: [sup-talk] [PATCH 2/2] Bounce Message Hook
Date: Sun,  7 Jun 2009 20:02:27 -0400	[thread overview]
Message-ID: <1244419347-11330-3-git-send-email-bwalton@artsci.utoronto.ca> (raw)
In-Reply-To: <1244419347-11330-2-git-send-email-bwalton@artsci.utoronto.ca>

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 at artsci.utoronto.ca>
---
 lib/sup.rb                        |    1 -
 lib/sup/modes/thread-view-mode.rb |   16 ++++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/sup.rb b/lib/sup.rb
index 76444c9..96510b2 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -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
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 8842e59..76a1d1e 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -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
-- 
1.6.3



  reply	other threads:[~2009-06-08  0:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08  0:02 [sup-talk] (no subject) Ben Walton
2009-06-08  0:02 ` [sup-talk] [PATCH 1/2] Add message bouncing capability Ben Walton
2009-06-08  0:02   ` Ben Walton [this message]
2009-06-11 23:50 ` [sup-talk] (no subject) Ben Walton
2009-06-12  3:44   ` William Morgan
2009-06-12 13:15     ` Ben Walton
2009-06-12 18:23 ` William Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1244419347-11330-3-git-send-email-bwalton@artsci.utoronto.ca \
    --to=bwalton@artsci.utoronto.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox