diff options
Diffstat (limited to 'src/mailman_pgp/runners/incoming.py')
| -rw-r--r-- | src/mailman_pgp/runners/incoming.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/mailman_pgp/runners/incoming.py b/src/mailman_pgp/runners/incoming.py index 5d55780..4a01b14 100644 --- a/src/mailman_pgp/runners/incoming.py +++ b/src/mailman_pgp/runners/incoming.py @@ -28,6 +28,12 @@ from mailman_pgp.model.list import PGPMailingList from mailman_pgp.pgp.wrapper import PGPWrapper +def _pass_default(msg, msgdata, listid): + inq = config.get('queues', 'in') + mailman_config.switchboards[inq].enqueue(msg, msgdata, + listid=listid) + + @public class IncomingRunner(Runner): def _dispose(self, mlist: MailingList, msg: Message, msgdata: dict): @@ -37,14 +43,27 @@ class IncomingRunner(Runner): pgp_list = PGPMailingList.query().filter_by( list_id=mlist.list_id).first() if not pgp_list: - inq = config.get('queues', 'in') - mailman_config.switchboards[inq].enqueue(msg, msgdata, - listid=mlist.list_id) + _pass_default(msg, msgdata, mlist.list_id) return False wrapped = PGPWrapper(msg) # Is the message encrypted? if wrapped.is_encrypted(): + list_key = pgp_list.key + if list_key is None: + raise ValueError('List key not found.') + decrypted = wrapped.decrypt(list_key) # noqa pass else: - pass + # Take the `nonencrypted_msg_action` + # just set some data for our `encryption` rule which will + # jump to the moderation chain if `pgp_moderate` is True + action = pgp_list.nonencrypted_msg_action + if action is not None: + msgdata['moderation_action'] = action + msgdata['moderation_sender'] = msg.sender + msgdata['moderation_reason'] = 'Message was not encrypted.' + msgdata['pgp_moderate'] = True + + _pass_default(msg, msgdata, mlist.list_id) + return False |
