Fix nulls showing in certificate rows

This commit is contained in:
Jamie Curnow
2026-05-18 15:04:27 +10:00
parent 32a74d9781
commit 1e22574000
+12 -10
View File
@@ -15,6 +15,16 @@ Model.knex(db());
const boolFields = ["is_deleted"];
const cleanDomainNames = (domainNames) => {
// Sort domain_names
if (typeof domainNames !== "undefined") {
const newDomainNames = domainNames.filter((name) => name !== null);
newDomainNames.sort();
return newDomainNames;
}
return [];
};
class Certificate extends Model {
$beforeInsert() {
this.created_on = now();
@@ -26,25 +36,17 @@ class Certificate extends Model {
}
// Default for domain_names
if (typeof this.domain_names === "undefined") {
this.domain_names = [];
}
this.domain_names = cleanDomainNames(this.domain_names);
// Default for meta
if (typeof this.meta === "undefined") {
this.meta = {};
}
this.domain_names.sort();
}
$beforeUpdate() {
this.modified_on = now();
// Sort domain_names
if (typeof this.domain_names !== "undefined") {
this.domain_names.sort();
}
this.domain_names = cleanDomainNames(this.domain_names);
}
$parseDatabaseJson(json) {