Feature: Marking "Read" spam mails

master
İbrahim Akyel 3 years ago
parent 43598119b8
commit f65e2fc469

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

@ -207,7 +207,7 @@ def config_update(verbose=False, delete_objects=False):
'enable_imap', 'enable_pop', 'forward_enabled', 'enable_imap', 'enable_pop', 'forward_enabled',
'forward_destination', 'reply_enabled', 'forward_destination', 'reply_enabled',
'reply_subject', 'reply_body', 'displayed_name', '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: for user_config in users:
if verbose: if verbose:
print(str(user_config)) print(str(user_config))

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

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

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

@ -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')

@ -112,6 +112,7 @@ following are additional parameters that could be defined for users:
* reply_body * reply_body
* displayed_name * displayed_name
* spam_enabled * spam_enabled
* spam_mark_as_read
* spam_threshold * spam_threshold
Alias 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_startdate: '1900-01-01'
reply_subject: '' reply_subject: ''
spam_enabled: true spam_enabled: true
spam_mark_as_read: true
spam_threshold: 80 spam_threshold: 80
tokens: tokens:
- id: 1 - id: 1

Loading…
Cancel
Save