diff --git a/frontend/src/components/domains/DomainList.vue b/frontend/src/components/domains/DomainList.vue
index a7b1f7240..d704f6455 100644
--- a/frontend/src/components/domains/DomainList.vue
+++ b/frontend/src/components/domains/DomainList.vue
@@ -45,28 +45,11 @@
{{ item.domainalias_count }} aliases
-
- Disabled
- Pending
-
-
- MX
-
-
- DNSBL
-
-
+
+
+ {{ getDNSLabel(item.dns_global_status) }}
+
@@ -131,12 +114,11 @@ export default {
headers: [
{ text: 'Name', value: 'name' },
{ text: 'Aliases', value: 'domainalias_count' },
- { text: 'DNS status', value: 'dns_status', sortable: false },
+ { text: 'DNS status', value: 'dns_global_status', sortable: false, align: 'center' },
{ text: 'Sending limit', value: 'message_limit' },
{ text: 'Quota', value: 'allocated_quota_in_percent' },
{ text: this.$gettext('Actions'), value: 'actions', sortable: false, align: 'right' }
],
- deleteDomainMsg: this.$gettext('Confirm deletion?'),
selectedDomain: null,
showConfirmDialog: false,
search: '',
@@ -164,14 +146,35 @@ export default {
}
)
},
- getDNSTagType (value) {
- if (value === 'unknown') {
- return 'orange'
+ getDNSLabel (value) {
+ if (value === 'disabled') {
+ return this.$gettext('Disabled')
+ }
+ if (value === 'pending') {
+ return this.$gettext('Pending')
+ }
+ if (value === 'critical') {
+ return this.$gettext('Problem')
}
if (value === 'ok') {
- return 'warning'
+ return this.$gettext('Valid')
}
- return 'success'
+ return this.$gettext('Unknown')
+ },
+ getDNSTagType (value) {
+ if (value === 'disabled') {
+ return ''
+ }
+ if (value === 'pending') {
+ return 'info'
+ }
+ if (value === 'critical') {
+ return 'error'
+ }
+ if (value === 'ok') {
+ return 'success'
+ }
+ return 'warning'
},
loadAliases ({ item, value }) {
if (!value) {
diff --git a/modoboa/admin/models/domain.py b/modoboa/admin/models/domain.py
index eea6f9991..1a9b16d1a 100644
--- a/modoboa/admin/models/domain.py
+++ b/modoboa/admin/models/domain.py
@@ -149,26 +149,34 @@ class Domain(mixins.MessageLimitMixin, AdminObject):
return True
return False
- @cached_property
- def dns_status(self) -> dict:
- """Return information about current DNS status."""
+ @property
+ def dns_global_status(self) -> str:
+ """Return global DNS status."""
if not self.enable_dns_checks or self.uses_a_reserved_tld:
- return {"checks": "disabled"}
+ return "disabled"
elif self.awaiting_checks():
- return {"checks": "pending"}
- result = {"checks": "active"}
+ return "pending"
config = dict(param_tools.get_global_parameters("admin"))
- if config["enable_mx_checks"]:
- result["mx"] = "ok" if self.mxrecord_set.has_valids() else "ko"
- if config["enable_dnsbl_checks"]:
- if not self.dnsblresult_set.exists():
- status = "unknown"
- elif self.dnsblresult_set.blacklisted().exists():
- status = "ko"
- else:
- status = "ok"
- result["dnsbl"] = status
- return result
+ errors = []
+ if config["enable_mx_checks"] and not self.mxrecord_set.has_valids():
+ errors.append("mx")
+ if config["enable_dnsbl_checks"] and self.dnsblresult_set.blacklisted().exists():
+ errors.append("dnsbl")
+ if config["enable_spf_checks"]:
+ if self.spf_record is None or not self.spf_record.is_valid():
+ errors.append("spf")
+ if self.dkim_record is None or not self.dkim_record.is_valid():
+ errors.append("dkim")
+ if self.dmarc_record is None or not self.dmarc_record.is_valid():
+ errors.append("dmarc")
+ if config["enable_autoconfig_checks"]:
+ if self.autoconfig_record is None:
+ errors.append("autoconfig")
+ if self.autodiscover_record is None:
+ errors.append("autodiscover")
+ if len(errors) == 0:
+ return "ok"
+ return "critical"
@cached_property
def dnsbl_status_color(self):
diff --git a/modoboa/admin/serializers.py b/modoboa/admin/serializers.py
index 9deeeb0b6..a0d3951d0 100644
--- a/modoboa/admin/serializers.py
+++ b/modoboa/admin/serializers.py
@@ -52,10 +52,10 @@ class DomainSerializer(serializers.ModelSerializer):
"enable_dkim", "dkim_key_selector", "dkim_key_length",
"dkim_public_key", "dkim_private_key_path",
"mailbox_count", "mbalias_count", "domainalias_count",
- "dns_status", "message_limit"
+ "dns_global_status", "message_limit"
)
read_only_fields = (
- "pk", "dkim_public_key", "dns_status", "allocated_quota_in_percent"
+ "pk", "dkim_public_key", "dns_global_status", "allocated_quota_in_percent"
"mailbox_count", "mbalias_count", "domainalias_count",
"enable_dns_checks"
)