commit b0b00a3b3e27b6d0bd58f05d96269399b7592fce
parent 249e29577df6c173aa5a65c6564554c0bcb4b5ee
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Sat, 1 Sep 2007 06:28:45 +0000
signature hook
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@556 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -12,6 +12,18 @@ class EditMessageMode < LineCursorMode
MULTI_HEADERS = %w(To Cc Bcc)
NON_EDITABLE_HEADERS = %w(Message-Id Date)
+ HookManager.register "signature", <<EOS
+Generates a signature for a message.
+Variables:
+ header: an object that supports string-to-string hashtable-style access
+ to the raw headers for the message. E.g., header["From"],
+ header["To"], etc.
+ from_email: the email part of the From: line, or nil if empty
+Return value:
+ A string (multi-line ok) containing the text of the signature, or nil to
+ use the default signature.
+EOS
+
attr_reader :status
attr_accessor :body, :header
bool_reader :edited
@@ -290,8 +302,16 @@ private
end
def sig_lines
- p = PersonManager.person_for(@header["From"]) or return []
- sigfn = (AccountManager.account_for(p.email) ||
+ p = PersonManager.person_for(@header["From"])
+ from_email = p && p.email
+
+ ## first run the hook
+ hook_sig = HookManager.run "signature", :header => @header, :from_email => from_email
+ return ["", "-- "] + hook_sig.split("\n") if hook_sig
+
+ ## no hook, do default signature generation based on config.yaml
+ return [] unless from_email
+ sigfn = (AccountManager.account_for(from_email) ||
AccountManager.default_account).signature
if sigfn && File.exists?(sigfn)