mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Added last DNS checks execution date to Domain model.
This commit is contained in:
@@ -10,6 +10,13 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
@click="showConfigHelp = true"
|
@click="showConfigHelp = true"
|
||||||
></v-btn>
|
></v-btn>
|
||||||
|
<span
|
||||||
|
v-if="domain.last_dns_check_execution"
|
||||||
|
class="ml-2 text-body-2 font-italic text-grey"
|
||||||
|
>
|
||||||
|
({{ $gettext('Last check:') }}
|
||||||
|
{{ $date(domain.last_dns_check_execution) }})
|
||||||
|
</span>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<translate class="overline">MX records</translate>
|
<translate class="overline">MX records</translate>
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ class DomainSerializer(v1_serializers.DomainSerializer):
|
|||||||
"opened_alarms_count",
|
"opened_alarms_count",
|
||||||
"sent_messages",
|
"sent_messages",
|
||||||
"sent_messages_in_percent",
|
"sent_messages_in_percent",
|
||||||
|
"last_dns_check_execution",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ def handle_mailbox_operations():
|
|||||||
def launch_domain_dns_checks(domain_id: int):
|
def launch_domain_dns_checks(domain_id: int):
|
||||||
domain = models.Domain.objects.get(id=domain_id)
|
domain = models.Domain.objects.get(id=domain_id)
|
||||||
DNSChecker().run(domain)
|
DNSChecker().run(domain)
|
||||||
|
domain.last_dns_check_execution = timezone.now()
|
||||||
|
domain.save()
|
||||||
|
|
||||||
|
|
||||||
def handle_dns_checks():
|
def handle_dns_checks():
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.11 on 2026-02-23 14:31
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("admin", "0023_auto_20240320_1037"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="domain",
|
||||||
|
name="last_dns_check_execution",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -55,6 +55,7 @@ class Domain(mixins.MessageLimitMixin, AdminObject):
|
|||||||
default=True,
|
default=True,
|
||||||
help_text=gettext_lazy("Check to enable DNS checks for this domain"),
|
help_text=gettext_lazy("Check to enable DNS checks for this domain"),
|
||||||
)
|
)
|
||||||
|
last_dns_check_execution = models.DateTimeField(null=True, blank=True)
|
||||||
|
|
||||||
transport = models.OneToOneField(
|
transport = models.OneToOneField(
|
||||||
"transport.Transport", null=True, on_delete=models.SET_NULL
|
"transport.Transport", null=True, on_delete=models.SET_NULL
|
||||||
|
|||||||
@@ -242,7 +242,9 @@ class DNSBLTestCase(ModoTestCase):
|
|||||||
worker = SimpleWorker([queue], connection=queue.connection)
|
worker = SimpleWorker([queue], connection=queue.connection)
|
||||||
worker.work(burst=True)
|
worker.work(burst=True)
|
||||||
|
|
||||||
|
self.domain.refresh_from_db()
|
||||||
self.assertTrue(models.DNSBLResult.objects.filter(domain=self.domain).exists())
|
self.assertTrue(models.DNSBLResult.objects.filter(domain=self.domain).exists())
|
||||||
|
self.assertIsNot(self.domain.last_dns_check_execution, None)
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
models.DNSBLResult.objects.filter(domain=self.domain3).exists()
|
models.DNSBLResult.objects.filter(domain=self.domain3).exists()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user