[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH] Add sent-save-to hook.



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