diff options
| author | J08nY | 2017-06-18 02:08:19 +0200 |
|---|---|---|
| committer | J08nY | 2017-06-18 02:08:19 +0200 |
| commit | b8767a634966b2c4ea9b2c8a71174ca49e3c2f2f (patch) | |
| tree | ab55c0fc3f44342e7161245c015061ca306b593c /src/mailman_pgp/model/list.py | |
| parent | aa407033bdb43cf09b1eeff2aa06a80a78ee00d7 (diff) | |
| download | mailman-pgp-b8767a634966b2c4ea9b2c8a71174ca49e3c2f2f.tar.gz mailman-pgp-b8767a634966b2c4ea9b2c8a71174ca49e3c2f2f.tar.zst mailman-pgp-b8767a634966b2c4ea9b2c8a71174ca49e3c2f2f.zip | |
Diffstat (limited to 'src/mailman_pgp/model/list.py')
| -rw-r--r-- | src/mailman_pgp/model/list.py | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/mailman_pgp/model/list.py b/src/mailman_pgp/model/list.py index d6384af..4699599 100644 --- a/src/mailman_pgp/model/list.py +++ b/src/mailman_pgp/model/list.py @@ -1,11 +1,14 @@ """""" +from mailman.config import config as mailman_config from mailman.database.types import Enum, SAUnicode from mailman.interfaces.action import Action +from mailman.model.mailinglist import MailingList from public import public from sqlalchemy import Boolean, Column, Integer from mailman_pgp.model.base import Base +from mailman_pgp.pgp.keygen import KeyGenerator @public @@ -14,7 +17,7 @@ class EncryptedMailingList(Base): id = Column(Integer, primary_key=True) list_id = Column(SAUnicode, index=True) - key_fingerprint = Column(SAUnicode) + _key_fingerprint = Column('key_fingerprint', SAUnicode) unsigned_msg_action = Column(Enum(Action)) nonencrypted_msg_action = Column(Enum(Action)) strip_original_signature = Column(Boolean) @@ -23,10 +26,28 @@ class EncryptedMailingList(Base): def __init__(self, mlist): super().__init__() self.list_id = mlist.list_id - self._list_key = None + + self._key_generator = self._create_generator(mlist) + self._key_generator.start() + + def _create_generator(self, mlist): + return KeyGenerator(mlist.list_id, mlist.fqdn_listname) + + @property + def key_fingerprint(self): + if self._key_fingerprint is None: + if self._key_generator.has_key: + self._key_fingerprint = self._key_generator.key_fingerprint + else: + if not self._key_generator.is_alive(): + # TODO this is not the best solution, we should lookup the + # key by mlist.fqdn_listname, if it actually got created + # and key generator didn't receive it. + self._key_generator = self._create_generator(self.mlist) + self._key_generator.start() + return self._key_fingerprint @property - def list_key(self): - if self._list_key is not None: - return self._list_key - pass + def mlist(self): + return mailman_config.db.query(MailingList).filter_by( + _list_id=self.list_id).first() |
