summaryrefslogtreecommitdiff
path: root/src/mailman_pgp/runners
diff options
context:
space:
mode:
authorJ08nY2017-06-24 01:59:24 +0200
committerJ08nY2017-06-24 01:59:24 +0200
commit52ab7fcef755d0adea8a23b5aa77e30119356ac1 (patch)
tree14c9c03dcd8c598109ca73b7c6d7f4d7d1d43061 /src/mailman_pgp/runners
parentfc3791771047b44143868c6dc5f113e4f9157bf5 (diff)
downloadmailman-pgp-52ab7fcef755d0adea8a23b5aa77e30119356ac1.tar.gz
mailman-pgp-52ab7fcef755d0adea8a23b5aa77e30119356ac1.tar.zst
mailman-pgp-52ab7fcef755d0adea8a23b5aa77e30119356ac1.zip
Diffstat (limited to 'src/mailman_pgp/runners')
-rw-r--r--src/mailman_pgp/runners/incoming.py27
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