# 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 . """""" import copy from mailman.email.message import UserNotification from mailman.interfaces.subscriptions import TokenOwner from public import public from mailman_pgp.pgp.mime import MIMEWrapper from mailman_pgp.utils.email import overwrite_message 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('get_approval') def _step_get_approval(self): self._pend(TokenOwner.moderator) self.push('receive_confirmation') self.save() if self.mlist.admin_immed_notify: subject = 'New key change request from {}'.format( 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) out = copy.deepcopy(msg) wrapped = MIMEWrapper(msg) msg = wrapped.attach_keys(self.pubkey) overwrite_message(msg, out) out.send(self.mlist) raise StopIteration