Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] Add sent-save-to hook.
@ 2012-08-29  1:42 Edward Z. Yang
  0 siblings, 0 replies; only message in thread
From: Edward Z. Yang @ 2012-08-29  1:42 UTC (permalink / raw)
  To: sup-devel

From: "Edward Z. Yang" <ezyang@mit.edu>

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
---
 lib/sup/modes/edit-message-mode.rb | 13 ++++++++++++-
 lib/sup/sent.rb                    |  7 ++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 5947ffd..2daffaf 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -69,6 +69,16 @@ Return value:
      True if mail has been sent successfully, false otherwise.
 EOS
 
+  HookManager.register "sent-save-to", <<EOS
+Configures where to save sent mail to. If this hook doesn't exist,
+the global sent setting will be used (possibly defaulting to sup://sent)
+Variables:
+    message: RMail::Message instance of the mail to send.
+    account: Account instance matching the From address
+Return value:
+     Source to save mail to, nil to use default
+EOS
+
   attr_reader :status
   attr_accessor :body, :header
   bool_reader :edited
@@ -456,7 +466,8 @@ protected
         raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0
       end
 
-      SentManager.write_sent_message(date, from_email) { |f| f.puts sanitize_body(m.to_s) }
+      SentManager.write_sent_message(HookManager.run("sent-save-to", :message => m, :account => acct),
+                                     date, from_email) { |f| f.puts sanitize_body(m.to_s) }
       BufferManager.kill_buffer buffer
       BufferManager.flash "Message sent!"
       true
diff --git a/lib/sup/sent.rb b/lib/sup/sent.rb
index 0ca1fb1..e712dad 100644
--- a/lib/sup/sent.rb
+++ b/lib/sup/sent.rb
@@ -24,9 +24,10 @@ class SentManager
     @source
   end
 
-  def write_sent_message date, from_email, &block
-    @source.store_message date, from_email, &block
-    PollManager.poll_from @source
+  def write_sent_message src, date, from_email, &block
+    use_src = src || @source
+    use_src.store_message date, from_email, &block
+    PollManager.poll_from use_src
   end
 end
 
-- 
1.7.11.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-08-29  1:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-29  1:42 [sup-devel] [PATCH] Add sent-save-to hook Edward Z. Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox