From 2681a5cd91b2563a24cf41b5dafe491bae6106ab Mon Sep 17 00:00:00 2001 From: J08nY Date: Wed, 2 Aug 2017 17:01:21 +0200 Subject: Add moderator approval to key change workflow, optionally. --- src/mailman_pgp/workflows/mod_approval.py | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/mailman_pgp/workflows/mod_approval.py (limited to 'src/mailman_pgp/workflows/mod_approval.py') diff --git a/src/mailman_pgp/workflows/mod_approval.py b/src/mailman_pgp/workflows/mod_approval.py new file mode 100644 index 0000000..e7ff061 --- /dev/null +++ b/src/mailman_pgp/workflows/mod_approval.py @@ -0,0 +1,62 @@ +# Copyright (C) 2017 Jan Jancar +# +# This file is a part of the Mailman PGP plugin. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . + +"""""" + +from mailman.email.message import UserNotification +from mailman.interfaces.subscriptions import TokenOwner +from public import public + +from mailman_pgp.pgp.mime import MIMEWrapper + +MOD_APPROVAL_REQUEST = """\ +---------- +TODO: this is a pgp enabled list. +A subscriber with address {} requested a change of his key. +His new key is attached to this message. + +Fingerprint: {} +---------- +""" + + +@public +class ModeratorApprovalMixin: + def _step_mod_approval(self): + self.push('restore') + self.push('get_approval') + + def _step_get_approval(self): + self._set_token(TokenOwner.moderator) + self.push('restore') + self.save() + + if self.mlist.admin_immed_notify: + subject = 'New key change request to {} from {}'.format( + self.mlist.display_name, self.pgp_address.email) + text = MOD_APPROVAL_REQUEST.format(self.pgp_address.email, + self.pubkey.fingerprint) + msg = UserNotification( + self.mlist.owner_address, self.mlist.owner_address, + subject, text, self.mlist.preferred_language) + wrapped = MIMEWrapper(msg) + msg = wrapped.attach_keys(self.pubkey) + msg.send(self.mlist) + raise StopIteration + + def _step_restore(self): + self._set_token(TokenOwner.no_one) -- cgit v1.2.3-70-g09d2