sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 96f349aabe931e097108333858185eb9b639f077
parent d52179696306cd23334b7c947d3b14372e0661f0
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Wed, 30 Jul 2008 17:16:55 -0700

Merge commit 'origin/reply-from-hook'

Diffstat:
M lib/sup/modes/reply-mode.rb | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
@@ -19,6 +19,16 @@ Return value:
   A string containing the text of the quote line (can be multi-line)
 EOS
 
+  HookManager.register "reply-from", <<EOS
+Selects a default address for the From: header of a new reply.
+Variables:
+  message: a message object representing the message being replied to
+    (useful values include message.recipient_email, message.to, and message.cc)
+Return value:
+  A Person to be used as the default for the From: header, or nil to use the
+  default behavior.
+EOS
+
   def initialize message
     @m = message
 
@@ -29,8 +39,19 @@ EOS
 
     ## first, determine the address at which we received this email. this will
     ## become our From: address in the reply.
+    hook_reply_from = HookManager.run "reply-from", :message => @m
+
+    ## sanity check that selection is a Person (or we'll fail below)
+    ## don't check that it's an Account, though; assume they know what they're doing.
+    if hook_reply_from && !(hook_reply_from.is_a? Person)
+        Redwood::log "reply-from returned non-Person, using default from."
+        hook_reply_from = nil
+    end
+
     from =
-      if @m.recipient_email && AccountManager.is_account_email?(@m.recipient_email)
+      if hook_reply_from
+        hook_reply_from
+      elsif @m.recipient_email && AccountManager.is_account_email?(@m.recipient_email)
         PersonManager.person_for(@m.recipient_email)
       elsif(b = (@m.to + @m.cc).find { |p| AccountManager.is_account? p })
         b