From fa74b19f90b1b982ada8bee98d8cc3ae33ff664f Mon Sep 17 00:00:00 2001 From: Jumper78 <52802286+Jumper78@users.noreply.github.com> Date: Sun, 16 Feb 2025 21:08:19 +0000 Subject: [PATCH] added functionality that DNS DMARC entry for report is only shown when needed --- core/admin/mailu/models.py | 18 ++++++++++++++++++ .../mailu/ui/templates/domain/details.html | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index c16a0ab2..f32a9533 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -247,6 +247,15 @@ class Domain(Base): ruf = f' ruf=mailto:{ruf}@{domain};' if ruf else '' return f'_dmarc.{self.name}. 600 IN TXT "v=DMARC1; p=reject;{rua}{ruf} adkim=s; aspf=s"' + @cached_property + def dns_dmarc_report_needed(self): + """ return true if DMARC report record is needed """ + domain = app.config['DOMAIN'] + if self.name != domain: + return True + else: + return False + @cached_property def dns_dmarc_report(self): """ return DMARC report record for mailu server """ @@ -373,6 +382,15 @@ class Alternative(Base): ruf = f' ruf=mailto:{ruf}@{domain};' if ruf else '' return f'_dmarc.{self.name}. 600 IN TXT "v=DMARC1; p=reject;{rua}{ruf} adkim=s; aspf=s"' + @cached_property + def dns_dmarc_report_needed(self): + """ return true if DMARC report record is needed """ + domain = app.config['DOMAIN'] + if self.name != domain: + return True + else: + return False + @cached_property def dns_dmarc_report(self): """ return DMARC report record for mailu server """ diff --git a/core/admin/mailu/ui/templates/domain/details.html b/core/admin/mailu/ui/templates/domain/details.html index 035ba7ae..de69be97 100644 --- a/core/admin/mailu/ui/templates/domain/details.html +++ b/core/admin/mailu/ui/templates/domain/details.html @@ -44,7 +44,9 @@
{{ domain.dns_dmarc }}
+ {%- if domain.dns_dmarc_report_needed %}
{{ macros.clip("dns_dmarc_report") }}{{ domain.dns_dmarc_report }}
+ {%- endif %}
{{ alternative.dns_dmarc }}
+ {%- if alternative.dns_dmarc_report_needed %}
{{ macros.clip("dns_dmarc_report") }}{{ alternative.dns_dmarc_report }}
+ {%- endif %}