commit 802e2f41583c7703f0e3a96f61b79cdb6a30f8cd
parent da24cdbb98b974e52c3d3b4df17e5f07b892adca
Author: Hamish Downer <dmishd@gmail.com>
Date: Wed, 20 Feb 2013 13:32:49 -0800
Merge pull request #7 from ericweikl/gpg-expand-keys
Add new hook 'gpg-expand-keys'
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -41,6 +41,20 @@ from_key: the key that generated the signature (class is GPGME::Key)
Return value: an array of lines of output
EOS
+ HookManager.register "gpg-expand-keys", <<EOS
+Runs when the list of encryption recipients is created, allowing you to
+replace a recipient with one or more GPGME recipients. For example, you could
+replace the email address of a mailing list with the key IDs that belong to
+the recipients of that list. This is essentially what GPG groups do, which
+are not supported by GPGME.
+
+Variables:
+recipients: an array of recipients of the current email
+
+Return value: an array of recipients (email address or GPG key ID) to encrypt
+the email for
+EOS
+
def initialize
@mutex = Mutex.new
@@ -137,7 +151,7 @@ EOS
gpg_opts = HookManager.run("gpg-options",
{:operation => "encrypt", :options => gpg_opts}) || gpg_opts
recipients = to + [from]
-
+ recipients = HookManager.run("gpg-expand-keys", { :recipients => recipients }) || recipients
begin
cipher = GPGME.encrypt(recipients, format_payload(payload), gpg_opts)
rescue GPGME::Error => exc