Able to set a generic subject for PGP-enabled mailbox

This commit is contained in:
Son NK 2020-11-07 12:58:51 +01:00
parent 7cc57106de
commit f57f29a97b
2 changed files with 74 additions and 1 deletions

View File

@ -6,6 +6,17 @@
Mailbox {{ mailbox.email }}
{% endblock %}
{% block head %}
<style>
div[disabled]
{
pointer-events: none;
opacity: 0.7;
}
</style>
{% endblock %}
{% block default_content %}
<div class="row">
@ -72,7 +83,7 @@
<div class="card-body">
<div class="card-title">
Pretty Good Privacy (PGP)
<div class="small-text">
<div class="small-text mt-1">
By importing your PGP Public Key into SimpleLogin, all emails sent to {{ mailbox.email }} are
<b>encrypted</b> with your key.
</div>
@ -106,6 +117,45 @@
</div>
<div class="card" {% if not mailbox.pgp_finger_print %} disabled {% endif %}>
<form method="post">
<input type="hidden" name="form-name" value="generic-subject">
<div class="card-body">
<div class="card-title">
Hide email subject when PGP is enabled
<div class="small-text mt-1">
When PGP is enabled, you can choose to use a <b>generic</b> subject for the forwarded emails.
The original subject is then added into the email body. <br>
As PGP does not encrypt the email subject and the email subject might contain sensitive information,
this option will allow a further protection of your email content.
</div>
</div>
<div class="form-group">
<label class="form-label">Generic Subject</label>
<input name="generic-subject"
{% if not mailbox.pgp_finger_print %} disabled {% endif %}
class="form-control" maxlength="78"
placeholder="Generic Subject"
value="{{ mailbox.generic_subject or "" }}"
>
</div>
<button class="btn btn-primary" name="action"
{% if not mailbox.pgp_finger_print %} disabled {% endif %}
value="save">Save
</button>
{% if mailbox.generic_subject %}
<button class="btn btn-danger float-right" name="action" value="remove">Remove</button>
{% endif %}
</div>
</form>
</div>
<hr>
<h2 class="h4">Advanced Options</h2>

View File

@ -151,6 +151,29 @@ def mailbox_detail_route(mailbox_id):
return redirect(
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
)
elif request.form.get("form-name") == "generic-subject":
if request.form.get("action") == "save":
if not mailbox.pgp_finger_print:
flash(
"Generic subject can only be used on PGP-enabled mailbox", "error"
)
return redirect(
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
)
mailbox.generic_subject = request.form.get("generic-subject")
db.session.commit()
flash("Generic subject for PGP-encrypted email is enabled", "success")
return redirect(
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
)
elif request.form.get("action") == "remove":
mailbox.generic_subject = None
db.session.commit()
flash("Generic subject for PGP-encrypted email is disabled", "success")
return redirect(
url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
)
spf_available = ENFORCE_SPF
return render_template("dashboard/mailbox_detail.html", **locals())