From fcad52b1454aeeb5b11d64fe0186f644922f96b2 Mon Sep 17 00:00:00 2001
From: kaiyou
Date: Thu, 27 Sep 2018 22:45:16 +0200
Subject: [PATCH 01/39] Implement a start date filter for autoreply, fixes #362
---
core/admin/mailu/models.py | 2 ++
core/admin/mailu/ui/forms.py | 1 +
core/admin/mailu/ui/templates/user/reply.html | 7 ++++--
.../migrations/versions/3b281286c7bd_.py | 24 +++++++++++++++++++
core/dovecot/conf/pigeonhole-sieve.dict | 8 +++++++
core/dovecot/sieve/before.sieve | 1 +
6 files changed, 41 insertions(+), 2 deletions(-)
create mode 100644 core/admin/migrations/versions/3b281286c7bd_.py
diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py
index 71c5f4d7..1be4c8e6 100644
--- a/core/admin/mailu/models.py
+++ b/core/admin/mailu/models.py
@@ -249,6 +249,8 @@ class User(Base, Email):
reply_enabled = db.Column(db.Boolean(), nullable=False, default=False)
reply_subject = db.Column(db.String(255), nullable=True, default=None)
reply_body = db.Column(db.Text(), nullable=True, default=None)
+ reply_startdate = db.Column(db.Date, nullable=False,
+ default=date(1900, 1, 1))
reply_enddate = db.Column(db.Date, nullable=False,
default=date(2999, 12, 31))
diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py
index 326d721b..4f7a30ae 100644
--- a/core/admin/mailu/ui/forms.py
+++ b/core/admin/mailu/ui/forms.py
@@ -117,6 +117,7 @@ class UserReplyForm(flask_wtf.FlaskForm):
reply_subject = fields.StringField(_('Reply subject'))
reply_body = fields.StringField(_('Reply body'),
widget=widgets.TextArea())
+ reply_startdate = fields.html5.DateField(_('Start of vacation'))
reply_enddate = fields.html5.DateField(_('End of vacation'))
submit = fields.SubmitField(_('Update'))
diff --git a/core/admin/mailu/ui/templates/user/reply.html b/core/admin/mailu/ui/templates/user/reply.html
index 7906bc42..7225a178 100644
--- a/core/admin/mailu/ui/templates/user/reply.html
+++ b/core/admin/mailu/ui/templates/user/reply.html
@@ -13,14 +13,17 @@
{% endcall %}
diff --git a/core/admin/migrations/versions/3b281286c7bd_.py b/core/admin/migrations/versions/3b281286c7bd_.py
new file mode 100644
index 00000000..78e44a4c
--- /dev/null
+++ b/core/admin/migrations/versions/3b281286c7bd_.py
@@ -0,0 +1,24 @@
+""" Add a start day for vacations
+
+Revision ID: 3b281286c7bd
+Revises: 049fed905da7
+Create Date: 2018-09-27 22:20:08.158553
+
+"""
+
+revision = '3b281286c7bd'
+down_revision = '049fed905da7'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ with op.batch_alter_table('user') as batch:
+ batch.add_column(sa.Column('reply_startdate', sa.Date(), nullable=False,
+ server_default="1900-01-01"))
+
+
+def downgrade():
+ with op.batch_alter_table('user') as batch:
+ batch.drop_column('reply_startdate')
diff --git a/core/dovecot/conf/pigeonhole-sieve.dict b/core/dovecot/conf/pigeonhole-sieve.dict
index 917fce83..604371a8 100644
--- a/core/dovecot/conf/pigeonhole-sieve.dict
+++ b/core/dovecot/conf/pigeonhole-sieve.dict
@@ -41,3 +41,11 @@ map {
username_field = email
value_field = reply_enddate
}
+
+map {
+ pattern = priv/reply_startdate
+ table = user
+ username_field = email
+ value_field = reply_startdate
+}
+
diff --git a/core/dovecot/sieve/before.sieve b/core/dovecot/sieve/before.sieve
index 6ebc20c5..81d20f30 100644
--- a/core/dovecot/sieve/before.sieve
+++ b/core/dovecot/sieve/before.sieve
@@ -34,6 +34,7 @@ if exists "X-Virus" {
}
if allof (string :is "${extdata.reply_enabled}" "1",
+ currentdate :value "ge" "date" "${extdata.reply_startdate}",
currentdate :value "le" "date" "${extdata.reply_enddate}")
{
vacation :days 1 :subject "${extdata.reply_subject}" "${extdata.reply_body}";
From 11a8e49f059c4eb71a8f931edcbfa238d90873a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim=20M=C3=B6hlmann?=
Date: Tue, 16 Oct 2018 11:09:42 +0300
Subject: [PATCH 02/39] Compose file upgrade and define more variables for
setup
---
setup/flavors/compose/docker-compose.yml | 38 ++++++++++++------------
setup/flavors/compose/mailu.env | 16 +++++-----
2 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/setup/flavors/compose/docker-compose.yml b/setup/flavors/compose/docker-compose.yml
index fcf0c092..a82817af 100644
--- a/setup/flavors/compose/docker-compose.yml
+++ b/setup/flavors/compose/docker-compose.yml
@@ -2,7 +2,7 @@
# This file is auto-generated by the Mailu configuration wizard.
# Please read the documentation before attempting any change.
-version: '2'
+version: '3.7'
services:
@@ -11,7 +11,7 @@ services:
image: redis:alpine
restart: always
volumes:
- - "$ROOT/redis:/data"
+ - "{{ root }}/redis:/data"
# Core services
front:
@@ -24,15 +24,15 @@ services:
ports:
{% for port in (80, 443, 25, 465, 587, 110, 995, 143, 993) %}
{% if bind4 %}
- - "$PUBLIC_IPV4:{{ port }}:{{ port }}"
+ - "{{ bind4}}:{{ port }}:{{ port }}"
{% endif %}
{% if bind6 %}
- - "$PUBLIC_IPV6:{{ port }}:{{ port }}"
+ - "{{ bind6 }}:{{ port }}:{{ port }}"
{% endif %}
{% endfor %}
{% if flavor in ('cert', 'mail') %}
volumes:
- - "$ROOT/certs:/certs"
+ - "{{ root }}/certs:/certs"
{% endif %}
admin:
@@ -44,8 +44,8 @@ services:
- 127.0.0.1:8080:80
{% endif %}
volumes:
- - "$ROOT/data:/data"
- - "$ROOT/dkim:/dkim"
+ - "{{ root }}/data:/data"
+ - "{{ root }}/dkim:/dkim"
depends_on:
- redis
@@ -54,9 +54,9 @@ services:
restart: always
env_file: {{ env }}
volumes:
- - "$ROOT/data:/data"
- - "$ROOT/mail:/mail"
- - "$ROOT/overrides:/overrides"
+ - "{{ root }}/data:/data"
+ - "{{ root }}/mail:/mail"
+ - "{{ root }}/overrides:/overrides"
depends_on:
- front
@@ -65,8 +65,8 @@ services:
restart: always
env_file: {{ env }}
volumes:
- - "$ROOT/data:/data"
- - "$ROOT/overrides:/overrides"
+ - "{{ root }}/data:/data"
+ - "{{ root }}/overrides:/overrides"
depends_on:
- front
@@ -77,9 +77,9 @@ services:
restart: always
env_file: {{ env }}
volumes:
- - "$ROOT/filter:/var/lib/rspamd"
- - "$ROOT/dkim:/dkim"
- - "$ROOT/overrides/rspamd:/etc/rspamd/override.d"
+ - "{{ root }}/filter:/var/lib/rspamd"
+ - "{{ root }}/dkim:/dkim"
+ - "{{ root }}/overrides/rspamd:/etc/rspamd/override.d"
depends_on:
- front
{% endif %}
@@ -90,7 +90,7 @@ services:
restart: always
env_file: {{ env }}
volumes:
- - "$ROOT/filter:/data"
+ - "{{ root }}/filter:/data"
{% endif %}
{% if enable_webdav %}
@@ -99,7 +99,7 @@ services:
restart: always
env_file: {{ env }}
volumes:
- - "$ROOT/dav:/data"
+ - "{{ root }}/dav:/data"
{% endif %}
{% if enable_fetchmail %}
@@ -108,7 +108,7 @@ services:
restart: always
env_file: {{ env }}
volumes:
- - "$ROOT/data:/data"
+ - "{{ root }}/data:/data"
{% endif %}
# Webmail
@@ -118,7 +118,7 @@ services:
restart: always
env_file: {{ env }}
volumes:
- - "$ROOT/webmail:/data"
+ - "{{ root }}/webmail:/data"
depends_on:
- imap
{% endif %}
diff --git a/setup/flavors/compose/mailu.env b/setup/flavors/compose/mailu.env
index 24d7b247..2de771f3 100644
--- a/setup/flavors/compose/mailu.env
+++ b/setup/flavors/compose/mailu.env
@@ -9,14 +9,16 @@
###################################
# Set this to the path where Mailu data and configuration is stored
-ROOT=/mailu
+# This variable is now set directly in `docker-compose.yml by the setup utility
+# ROOT=/mailu
# Set to a randomly generated 16 bytes string
SECRET_KEY={{ secret(16) }}
# Address where listening ports should bind
-{% if bind4 %}PUBLIC_IPV4={{ bind4 }}{% endif %}
-{% if bind6 %}PUBLIC_IPV6={{ bind6 }}{% endif %}
+# This variables are now set directly in `docker-compose.yml by the setup utility
+# PUBLIC_IPV4=127.0.0.1
+# PUBLIC_IPV6=::1
# Mail address of the postmaster
POSTMASTER={{ postmaster }}
@@ -75,16 +77,16 @@ DOMAIN_REGISTRATION=true
###################################
# Path to the admin interface if enabled
-WEB_ADMIN=/admin
+WEB_ADMIN={{ admin_path }}
# Path to the webmail if enabled
-WEB_WEBMAIL=/webmail
+WEB_WEBMAIL={{ webmail_path }}
# Website name
-SITENAME=Mailu
+SITENAME={{ site_name }{
# Linked Website URL
-WEBSITE=https://mailu.io
+WEBSITE={{ website }}
{% if recaptcha_public_key and recaptcha_private_key %}
# Registration reCaptcha settings (warning, this has some privacy impact)
From 0d164486b45b194de81905089b37a4557a828a8f Mon Sep 17 00:00:00 2001
From: Ionut Filip
Date: Tue, 16 Oct 2018 12:34:55 +0300
Subject: [PATCH 03/39] docker-compose variables and setup
---
setup/Dockerfile | 4 +++-
setup/docker-compose.yml | 1 +
setup/flavors/compose/docker-compose.yml | 2 +-
setup/flavors/compose/mailu.env | 8 ++++----
setup/flavors/compose/setup.html | 6 +++---
setup/server.py | 6 ++++--
setup/templates/steps/expose.html | 4 ++--
setup/templates/steps/root.html | 8 ++++++++
setup/templates/wizard.html | 1 +
9 files changed, 27 insertions(+), 13 deletions(-)
create mode 100644 setup/templates/steps/root.html
diff --git a/setup/Dockerfile b/setup/Dockerfile
index 1fc808f1..c970e57d 100644
--- a/setup/Dockerfile
+++ b/setup/Dockerfile
@@ -10,8 +10,10 @@ RUN apk add --no-cache git \
COPY server.py ./server.py
COPY setup.py ./setup.py
COPY main.py ./main.py
+COPY flavors /data/master/flavors
+COPY templates /data/master/templates
-RUN python setup.py https://github.com/mailu/mailu /data
+#RUN python setup.py https://github.com/mailu/mailu /data
EXPOSE 80/tcp
diff --git a/setup/docker-compose.yml b/setup/docker-compose.yml
index 9288bb7e..30966167 100644
--- a/setup/docker-compose.yml
+++ b/setup/docker-compose.yml
@@ -10,4 +10,5 @@ services:
image: mailu/setup
ports:
- "80:80"
+ build: .
diff --git a/setup/flavors/compose/docker-compose.yml b/setup/flavors/compose/docker-compose.yml
index a82817af..3dcfa5a2 100644
--- a/setup/flavors/compose/docker-compose.yml
+++ b/setup/flavors/compose/docker-compose.yml
@@ -24,7 +24,7 @@ services:
ports:
{% for port in (80, 443, 25, 465, 587, 110, 995, 143, 993) %}
{% if bind4 %}
- - "{{ bind4}}:{{ port }}:{{ port }}"
+ - "{{ bind4 }}:{{ port }}:{{ port }}"
{% endif %}
{% if bind6 %}
- "{{ bind6 }}:{{ port }}:{{ port }}"
diff --git a/setup/flavors/compose/mailu.env b/setup/flavors/compose/mailu.env
index 2de771f3..1512e75b 100644
--- a/setup/flavors/compose/mailu.env
+++ b/setup/flavors/compose/mailu.env
@@ -10,15 +10,15 @@
# Set this to the path where Mailu data and configuration is stored
# This variable is now set directly in `docker-compose.yml by the setup utility
-# ROOT=/mailu
+# ROOT= {{ root }}
# Set to a randomly generated 16 bytes string
SECRET_KEY={{ secret(16) }}
# Address where listening ports should bind
# This variables are now set directly in `docker-compose.yml by the setup utility
-# PUBLIC_IPV4=127.0.0.1
-# PUBLIC_IPV6=::1
+# PUBLIC_IPV4= {{ bind4 }} (default: 127.0.0.1)
+# PUBLIC_IPV6= {{ bind6 }} (default: ::1)
# Mail address of the postmaster
POSTMASTER={{ postmaster }}
@@ -83,7 +83,7 @@ WEB_ADMIN={{ admin_path }}
WEB_WEBMAIL={{ webmail_path }}
# Website name
-SITENAME={{ site_name }{
+SITENAME={{ site_name }}
# Linked Website URL
WEBSITE={{ website }}
diff --git a/setup/flavors/compose/setup.html b/setup/flavors/compose/setup.html
index e4506e6d..3c190c9c 100644
--- a/setup/flavors/compose/setup.html
+++ b/setup/flavors/compose/setup.html
@@ -4,13 +4,13 @@
Docker Compose expects a project file, named docker-compose.yml
in a project directory. First create your project directory.
-mkdir /mailu
+mkdir {{ root }}
Then download the project file. A side configuration file makes it easier
to read and check the configuration variables generated by the wizard.
-cd /mailu
+cd {{ root }}
wget {{ url_for('.file', uid=uid, filepath='docker-compose.yml', _external=True) }}
wget {{ url_for('.file', uid=uid, filepath='mailu.env', _external=True) }}
@@ -30,7 +30,7 @@ files before going any further.
To start your compose project, simply run the Docker Compose up
command.
-cd /mailu
+cd {{ root }}
docker-compose up -d
{% endcall %}
diff --git a/setup/server.py b/setup/server.py
index 108f5043..ddeafd90 100644
--- a/setup/server.py
+++ b/setup/server.py
@@ -32,9 +32,11 @@ def secret(length=16):
def build_app(path):
+ #Hardcoded master as the only version for test purposes
versions = [
- version for version in os.listdir(path)
- if os.path.isdir(os.path.join(path, version))
+ # version for version in os.listdir(path)
+ # if os.path.isdir(os.path.join(path, version))
+ "master"
]
app.jinja_env.trim_blocks = True
diff --git a/setup/templates/steps/expose.html b/setup/templates/steps/expose.html
index 665b08a2..372ebddc 100644
--- a/setup/templates/steps/expose.html
+++ b/setup/templates/steps/expose.html
@@ -14,12 +14,12 @@ avoid generic all-interfaces addresses like 0.0.0.0
or ::
IPv4 listen address
-
+
IPv6 listen address
-
+
You server will be available under a main hostname but may expose multiple public
diff --git a/setup/templates/steps/root.html b/setup/templates/steps/root.html
new file mode 100644
index 00000000..f32c2250
--- /dev/null
+++ b/setup/templates/steps/root.html
@@ -0,0 +1,8 @@
+{% call macros.panel("info", "Step 0 - Set root path") %}
+
Before starting root path must be set
+
+
+ Root path:
+
+
+{% endcall %}
diff --git a/setup/templates/wizard.html b/setup/templates/wizard.html
index da9d5134..bbebe569 100644
--- a/setup/templates/wizard.html
+++ b/setup/templates/wizard.html
@@ -9,6 +9,7 @@
{% endcall %}