* [sup-talk] (no subject) @ 2009-06-08 0:02 Ben Walton 2009-06-08 0:02 ` [sup-talk] [PATCH 1/2] Add message bouncing capability Ben Walton ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Ben Walton @ 2009-06-08 0:02 UTC (permalink / raw) Hi All, Here's a stab at implementing a message bouncing functionality worthy of being included on mainline. The first patch adds the basic functionality with the ability to supply a command in the :bounce_sendmail option that overrides the default command used. The default is to use the sendmail command of the default account with -t removed. The second patch takes this a step further and strips the configuration option in favour of a hook named bounce-command. This hooks gets the From header of the message being bounced and an array of recipient addresses supplied by the user. I think these are in good shape, with the caveat that the mail sending (IO.popen) part could still be refactored with the code in edit-message-mode. Anyone interested can grab this code from the bw/bounce_message branch of git://code.chass.utoronto.ca/bwalton-sup.git. It merges cleanly into next as of now. Feedback welcome. Thanks -Ben ^ permalink raw reply [flat|nested] 7+ messages in thread
* [sup-talk] [PATCH 1/2] Add message bouncing capability 2009-06-08 0:02 [sup-talk] (no subject) Ben Walton @ 2009-06-08 0:02 ` Ben Walton 2009-06-08 0:02 ` [sup-talk] [PATCH 2/2] Bounce Message Hook Ben Walton 2009-06-11 23:50 ` [sup-talk] (no subject) Ben Walton 2009-06-12 18:23 ` William Morgan 2 siblings, 1 reply; 7+ messages in thread From: Ben Walton @ 2009-06-08 0:02 UTC (permalink / raw) Bouncing a message is akin to redirecting a mail with a .forward entry. It is passed back to the mail system as it sits on disk. By pressing ! while viewing a message, you can now re-inject it to the mail system using either the command defined in bounce_sendmail or the sendmail command for the default account with any instance of -t removed. The user is prompted for the recipients of the message and is offered a chance to confirm the bounce before it is sent. The message is _not_ stored in the sent box, as this doesn't make sense with bounced messages (and would not show up uniquely anyway). The bounce_sendmail configuration item allows users that require different sendmail commands depending on where the bounce is destined to write a wrapper around their local mail tools to pick and choose the appropriate injection method for the message based on the addresses passed in. Most systems can likely use: sendmail -oem -i Signed-off-by: Ben Walton <bwalton at artsci.utoronto.ca> --- lib/sup.rb | 1 + lib/sup/modes/thread-view-mode.rb | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/lib/sup.rb b/lib/sup.rb index 96510b2..76444c9 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -207,6 +207,7 @@ 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 42c6280..8842e59 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -41,6 +41,7 @@ EOS # k.add :collapse_non_new_messages, "Collapse all but unread messages", 'N' k.add :reply, "Reply to a message", 'r' k.add :forward, "Forward a message or attachment", 'f' + k.add :bounce, "Bounce message to other recipient(s)", '!' k.add :alias, "Edit alias/nickname for a person", 'i' k.add :edit_as_new, "Edit message as new", 'D' k.add :save_to_disk, "Save message/attachment to disk", 's' @@ -172,6 +173,38 @@ EOS end end + def bounce + m = @message_lines[curpos] or return + to = BufferManager.ask_for_contacts(:people, "Bounce To: ") or return + + defcmd = AccountManager.default_account.sendmail.sub(/\s(\-(ti|it|t))\b/) do |match| + case "$1" + when '-t' then '' + else ' -i' + end + end + + cmd = case $config[:bounce_sendmail] + when nil, /^$/ then defcmd + else $config[:bounce_sendmail] + end + ' ' + to.map { |t| t.email }.join(' ') + + bt = to.size > 1 ? "#{to.size} recipients" : to.to_s + + if BufferManager.ask_yes_or_no "Really bounce to #{bt}?" + Redwood::log "Bounce Command: #{cmd}" + begin + IO.popen(cmd, 'w') do |sm| + sm.puts m.raw_message + end + raise SendmailCommandFailed, "Couldn't execute #{cmd}" unless $? == 0 + rescue SystemCallError, SendmailCommandFailed => e + Redwood::log "Problem sending mail: #{e.message}" + BufferManager.flash "Problem sending mail: #{e.message}" + end + end + end + include CanAliasContacts def alias p = @person_lines[curpos] or return -- 1.6.3 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [sup-talk] [PATCH 2/2] Bounce Message Hook 2009-06-08 0:02 ` [sup-talk] [PATCH 1/2] Add message bouncing capability Ben Walton @ 2009-06-08 0:02 ` Ben Walton 0 siblings, 0 replies; 7+ messages in thread From: Ben Walton @ 2009-06-08 0:02 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [sup-talk] (no subject) 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-11 23:50 ` Ben Walton 2009-06-12 3:44 ` William Morgan 2009-06-12 18:23 ` William Morgan 2 siblings, 1 reply; 7+ messages in thread From: Ben Walton @ 2009-06-11 23:50 UTC (permalink / raw) Excerpts from Ben Walton's message of Sun Jun 07 20:02:25 -0400 2009: Hi William, > Here's a stab at implementing a message bouncing functionality worthy > of being included on mainline. Is there something you don't like about these patches or have you just been too busy to look at them? I could collapse them into a single patch, thus removing any trace of using $config instead of a Hook, to keep the history cleaner if you'd prefer. If there is something else you'd like to see changed before picking it up, let me know. Thanks -Ben -- Ben Walton Systems Programmer - CHASS University of Toronto C:416.407.5610 | W:416.978.4302 GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu Contact me to arrange for a CAcert assurance meeting. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [sup-talk] (no subject) 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 0 siblings, 1 reply; 7+ messages in thread From: William Morgan @ 2009-06-12 3:44 UTC (permalink / raw) Reformatted excerpts from Ben Walton's message of 2009-06-11: > Is there something you don't like about these patches or have you just > been too busy to look at them? Just been busy. Sorry! My Sup time tends to be very bursty. I realize that's not great for contributors. Please have patience with your poor maintainer and feel free to keep bugging me. -- William <wmorgan-sup at masanjin.net> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [sup-talk] (no subject) 2009-06-12 3:44 ` William Morgan @ 2009-06-12 13:15 ` Ben Walton 0 siblings, 0 replies; 7+ messages in thread From: Ben Walton @ 2009-06-12 13:15 UTC (permalink / raw) Excerpts from William Morgan's message of Thu Jun 11 23:44:41 -0400 2009: > Reformatted excerpts from Ben Walton's message of 2009-06-11: > > Is there something you don't like about these patches or have you just > > been too busy to look at them? > > Just been busy. Sorry! My Sup time tends to be very bursty. I realize > that's not great for contributors. Please have patience with your poor > maintainer and feel free to keep bugging me. No problem. You're just very quick to respond typically, so I wanted to make sure that it hadn't fallen through the cracks... Thanks -Ben -- Ben Walton Systems Programmer - CHASS University of Toronto C:416.407.5610 | W:416.978.4302 GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu Contact me to arrange for a CAcert assurance meeting. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090612/0803c72a/attachment.bin> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [sup-talk] (no subject) 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-11 23:50 ` [sup-talk] (no subject) Ben Walton @ 2009-06-12 18:23 ` William Morgan 2 siblings, 0 replies; 7+ messages in thread From: William Morgan @ 2009-06-12 18:23 UTC (permalink / raw) Reformatted excerpts from Ben Walton's message of 2009-06-07: > Here's a stab at implementing a message bouncing functionality worthy > of being included on mainline. Looks good. I've merged this into next. Thanks! -- William <wmorgan-sup at masanjin.net> ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-06-12 18:23 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 ` [sup-talk] [PATCH 2/2] Bounce Message Hook Ben Walton 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox