diff --git a/modoboa/core/commands/templates/settings.py.tpl b/modoboa/core/commands/templates/settings.py.tpl index ad9246b76..1b58ce695 100644 --- a/modoboa/core/commands/templates/settings.py.tpl +++ b/modoboa/core/commands/templates/settings.py.tpl @@ -296,6 +296,12 @@ RQ_QUEUES = { 'DB': REDIS_QUOTA_DB, 'URL': REDIS_URL, }, + 'dovecot': { + 'HOST': REDIS_HOST, + 'PORT': REDIS_PORT, + 'DB': REDIS_QUOTA_DB, + 'URL': REDIS_URL, + }, } # CACHE diff --git a/modoboa/core/jobs.py b/modoboa/core/jobs.py new file mode 100644 index 000000000..2c8a1c621 --- /dev/null +++ b/modoboa/core/jobs.py @@ -0,0 +1,14 @@ +"""Core Jobs""" + + +def clean_log(): + import datetime + + from modoboa.core.models import Log + from modoboa.parameters import tools as param_tools + + from django.utils import timezone + + log_maximum_age = param_tools.get_global_parameter("log_maximum_age") + limit = timezone.now() - datetime.timedelta(log_maximum_age) + Log.objects.filter(date_created__lt=limit).delete() diff --git a/modoboa/core/management/commands/job_heartbeat.py b/modoboa/core/management/commands/job_heartbeat.py new file mode 100644 index 000000000..f182a92e2 --- /dev/null +++ b/modoboa/core/management/commands/job_heartbeat.py @@ -0,0 +1,32 @@ +import datetime +import logging + +from django.core.management.base import BaseCommand +from django.utils import timezone + +from modoboa.core.models import Log +from modoboa.parameters import tools as param_tools + +JOB_IDs = ["clearsessions_r", "cleanlogs_r", "logparser_r"] +AMAVIS_IDs = ["qcleanup_r", "amnotify_r"] + + +class Command(BaseCommand): + """Command class.""" + + help = "Checks that redondants jobs are started or start them" # NOQA:A003 + + def add_arguments(self, parser): + """Add extra arguments to command line.""" + parser.add_argument( + "--queue-now", + action="store_true", + default=False, + help="Queue all redondant job now", + ) + + def check_clean_log(queue_now=False): + pass + + def handle(self, *args, **options): + self.check_clean_log(options["queue_now"]) diff --git a/modoboa/core/password_hashers/base.py b/modoboa/core/password_hashers/base.py index dcba941df..9d821dc6f 100644 --- a/modoboa/core/password_hashers/base.py +++ b/modoboa/core/password_hashers/base.py @@ -5,7 +5,10 @@ Contains weak hashers (the original ones) available with Modoboa. """ import base64 + import hashlib +from random import Random +import string from typing import Optional from django.utils.crypto import constant_time_compare @@ -49,7 +52,7 @@ class PasswordHasher(metaclass=MetaHasher): def __init__(self, target="local"): self._target = target - def _encrypt(self, clearvalue: str, salt: Optional[str] = None) -> str: # NOQA + def _encrypt(self, clearvalue: str, salt: Optional[str] = None) -> str: raise NotImplementedError def _b64encode(self, pwhash): diff --git a/pyproject.toml b/pyproject.toml index f8d57efc7..7a6deed71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,7 @@ dependencies = [ # RQ "rq>=1.13.0", "django-rq", + "rq-scheduler", # Sieve "sievelib>=1.4.1", # User diff --git a/update_deps.sh b/update_deps.sh deleted file mode 100755 index 17e02ae5d..000000000 --- a/update_deps.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -pip-compile --output-file=requirements.txt pyproject.toml -pip-compile --extra=mysql --output-file=mysql-requirements.txt pyproject.toml -pip-compile --extra=postgresql --output-file=postgresql-requirements.txt pyproject.toml -pip-compile --extra=ldap --output-file=ldap-requirements.txt pyproject.toml -pip-compile --extra=dev --output-file=dev-requirements.txt pyproject.toml -pip-compile --extra=test --output-file=test-requirements.txt pyproject.toml