Use pgp_enabled() instead of pgp_finger_print
This commit is contained in:
parent
5997e5b5b5
commit
c707342695
|
@ -48,7 +48,7 @@
|
||||||
🚫
|
🚫
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if mailbox.pgp_finger_print %}
|
{% if mailbox.pgp_enabled() %}
|
||||||
<span class="cursor" data-toggle="tooltip" data-original-title="PGP Enabled">🗝</span>
|
<span class="cursor" data-toggle="tooltip" data-original-title="PGP Enabled">🗝</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
🚫
|
🚫
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if mailbox.pgp_finger_print %}
|
{% if mailbox.pgp_enabled() %}
|
||||||
<span class="cursor" data-toggle="tooltip" data-original-title="PGP Enabled">🗝</span>
|
<span class="cursor" data-toggle="tooltip" data-original-title="PGP Enabled">🗝</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card" {% if not mailbox.pgp_finger_print %} disabled {% endif %}>
|
<div class="card" {% if not mailbox.pgp_enabled() %} disabled {% endif %}>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="hidden" name="form-name" value="generic-subject">
|
<input type="hidden" name="form-name" value="generic-subject">
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
<label class="form-label">Generic Subject</label>
|
<label class="form-label">Generic Subject</label>
|
||||||
|
|
||||||
<input name="generic-subject"
|
<input name="generic-subject"
|
||||||
{% if not mailbox.pgp_finger_print %} disabled {% endif %}
|
{% if not mailbox.pgp_enabled() %} disabled {% endif %}
|
||||||
class="form-control" maxlength="78"
|
class="form-control" maxlength="78"
|
||||||
placeholder="Generic Subject"
|
placeholder="Generic Subject"
|
||||||
value="{{ mailbox.generic_subject or "" }}"
|
value="{{ mailbox.generic_subject or "" }}"
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary" name="action"
|
<button class="btn btn-primary" name="action"
|
||||||
{% if not mailbox.pgp_finger_print %} disabled {% endif %}
|
{% if not mailbox.pgp_enabled() %} disabled {% endif %}
|
||||||
value="save">Save
|
value="save">Save
|
||||||
</button>
|
</button>
|
||||||
{% if mailbox.generic_subject %}
|
{% if mailbox.generic_subject %}
|
||||||
|
|
|
@ -953,7 +953,7 @@ class Alias(db.Model, ModelMixin):
|
||||||
def mailbox_support_pgp(self) -> bool:
|
def mailbox_support_pgp(self) -> bool:
|
||||||
"""return True of one of the mailboxes support PGP"""
|
"""return True of one of the mailboxes support PGP"""
|
||||||
for mb in self.mailboxes:
|
for mb in self.mailboxes:
|
||||||
if mb.pgp_finger_print:
|
if mb.pgp_enabled():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1683,6 +1683,12 @@ class Mailbox(db.Model, ModelMixin):
|
||||||
|
|
||||||
user = db.relationship(User, foreign_keys=[user_id])
|
user = db.relationship(User, foreign_keys=[user_id])
|
||||||
|
|
||||||
|
def pgp_enabled(self) -> bool:
|
||||||
|
if self.pgp_finger_print and not self.disable_pgp:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def nb_alias(self):
|
def nb_alias(self):
|
||||||
return (
|
return (
|
||||||
AliasMailbox.filter_by(mailbox_id=self.id).count()
|
AliasMailbox.filter_by(mailbox_id=self.id).count()
|
||||||
|
|
|
@ -65,7 +65,7 @@ def encrypt_file(data: BytesIO, fingerprint: str) -> str:
|
||||||
# maybe the fingerprint is not loaded on this host, try to load it
|
# maybe the fingerprint is not loaded on this host, try to load it
|
||||||
found = False
|
found = False
|
||||||
# searching for the key in mailbox
|
# searching for the key in mailbox
|
||||||
mailbox = Mailbox.get_by(pgp_finger_print=fingerprint)
|
mailbox = Mailbox.get_by(pgp_finger_print=fingerprint, disable_pgp=False)
|
||||||
if mailbox:
|
if mailbox:
|
||||||
LOG.d("(re-)load public key for %s", mailbox)
|
LOG.d("(re-)load public key for %s", mailbox)
|
||||||
load_public_key(mailbox.pgp_public_key)
|
load_public_key(mailbox.pgp_public_key)
|
||||||
|
|
|
@ -662,7 +662,11 @@ def forward_email_to_mailbox(
|
||||||
)
|
)
|
||||||
|
|
||||||
# create PGP email if needed
|
# create PGP email if needed
|
||||||
if mailbox.pgp_finger_print and user.is_premium() and not alias.disable_pgp:
|
if (
|
||||||
|
mailbox.pgp_enabled()
|
||||||
|
and user.is_premium()
|
||||||
|
and not alias.disable_pgp
|
||||||
|
):
|
||||||
LOG.d("Encrypt message using mailbox %s", mailbox)
|
LOG.d("Encrypt message using mailbox %s", mailbox)
|
||||||
if mailbox.generic_subject:
|
if mailbox.generic_subject:
|
||||||
LOG.d("Use a generic subject for %s", mailbox)
|
LOG.d("Use a generic subject for %s", mailbox)
|
||||||
|
|
Loading…
Reference in a new issue