diff options
Diffstat (limited to 'src/mailman_pgp/workflows/mod_approval.py')
| -rw-r--r-- | src/mailman_pgp/workflows/mod_approval.py | 62 |
1 files changed, 62 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. + +"""""" + +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) |
