1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-03-11 14:49:19 +02:00

Feature: Marking "Read" spam mails

This commit is contained in:
İbrahim Akyel 2022-03-11 16:58:50 +03:00
parent 43598119b8
commit f65e2fc469
7 changed files with 29 additions and 1 deletions

View File

@ -21,7 +21,9 @@ if header :index 2 :matches "Received" "from * by * for <*>; *"
{% if user.spam_enabled %}
if spamtest :percent :value "gt" :comparator "i;ascii-numeric" "{{ user.spam_threshold }}"
{
{% if user.spam_mark_as_read %}
setflag "\\seen";
{% endif %}
fileinto :create "Junk";
stop;
}

View File

@ -207,7 +207,7 @@ def config_update(verbose=False, delete_objects=False):
'enable_imap', 'enable_pop', 'forward_enabled',
'forward_destination', 'reply_enabled',
'reply_subject', 'reply_body', 'displayed_name',
'spam_enabled', 'email', 'spam_threshold')
'spam_enabled', 'spam_mark_as_read', 'email', 'spam_threshold')
for user_config in users:
if verbose:
print(str(user_config))

View File

@ -505,6 +505,7 @@ class User(Base, Email):
# Settings
displayed_name = db.Column(db.String(160), nullable=False, default='')
spam_enabled = db.Column(db.Boolean, nullable=False, default=True)
spam_mark_as_read = db.Column(db.Boolean, nullable=False, default=True)
spam_threshold = db.Column(db.Integer, nullable=False, default=80)
# Flask-login attributes

View File

@ -100,6 +100,7 @@ class UserSignupFormCaptcha(UserSignupForm):
class UserSettingsForm(flask_wtf.FlaskForm):
displayed_name = fields.StringField(_('Displayed name'))
spam_enabled = fields.BooleanField(_('Enable spam filter'))
spam_mark_as_read = fields.BooleanField(_('Enable marking spam mails as read'))
spam_threshold = fields_.IntegerSliderField(_('Spam filter tolerance'))
forward_enabled = fields.BooleanField(_('Enable forwarding'))
forward_keep = fields.BooleanField(_('Keep a copy of the emails'))

View File

@ -18,6 +18,7 @@
{%- call macros.card(title=_("Antispam")) %}
{%- call macros.fieldset(field=form.spam_enabled, enabled=user.spam_enabled) %}
{{ macros.form_field(form.spam_mark_as_read) }}
{{ macros.form_field(form.spam_threshold, step=1, max=100,
prepend='<span class="input-group-text"><span id="spam_threshold_value"></span>&nbsp;/&nbsp;100</span>') }}
{%- endcall %}

View File

@ -0,0 +1,21 @@
"""empty message
Revision ID: 8f9ea78776f4
Revises: 3b7eee912b41
Create Date: 2022-03-11 13:53:08.996055
"""
# revision identifiers, used by Alembic.
revision = '8f9ea78776f4'
down_revision = '3b7eee912b41'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('user', sa.Column('spam_mark_as_read', sa.Boolean(), nullable=False))
def downgrade():
op.drop_column('user', 'spam_mark_as_read')

View File

@ -112,6 +112,7 @@ following are additional parameters that could be defined for users:
* reply_body
* displayed_name
* spam_enabled
* spam_mark_as_read
* spam_threshold
Alias
@ -293,6 +294,7 @@ This is a complete YAML template with all additional parameters that can be defi
reply_startdate: '1900-01-01'
reply_subject: ''
spam_enabled: true
spam_mark_as_read: true
spam_threshold: 80
tokens:
- id: 1