From bc2136db0d6fe189e9b379efbe6293d9859c9b12 Mon Sep 17 00:00:00 2001 From: iotux Date: Wed, 14 Jan 2026 12:36:53 +0100 Subject: [PATCH] removed findByMonitorDomainName --- server/model/domain_expiry.js | 34 +++----------------------------- test/backend-test/test-domain.js | 14 +------------ 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/server/model/domain_expiry.js b/server/model/domain_expiry.js index a9575c798..bf51e7996 100644 --- a/server/model/domain_expiry.js +++ b/server/model/domain_expiry.js @@ -10,9 +10,9 @@ const dayjs = require("dayjs"); const cachedFetch = process.env.NODE_ENV ? NodeFetchCache.create({ - // cache for 8h - cache: new MemoryCache({ ttl: 1000 * 60 * 60 * 8 }), - }) + // cache for 8h + cache: new MemoryCache({ ttl: 1000 * 60 * 60 * 8 }), + }) : fetch; /** @@ -173,14 +173,6 @@ class DomainExpiry extends BeanModel { const rdap = await getRdapServer(tld.publicSuffix); if (!rdap) { - // Only warn when the monitor actually has domain expiry notifications enabled. - // The edit monitor page calls this method frequently while the user is typing. - if (Boolean(monitor.domainExpiryNotification)) { - log.warn( - "domain_expiry", - `Domain expiry unsupported for '.${tld.publicSuffix}' because its RDAP endpoint is not listed in the IANA database.` - ); - } throw new TranslatableError("domain_expiry_unsupported_unsupported_tld_no_rdap_endpoint", { publicSuffix: tld.publicSuffix, }); @@ -192,26 +184,6 @@ class DomainExpiry extends BeanModel { }; } - /** - * @param {Monitor} monitor Monitor object - * @throws {TranslatableError} Throws an error if the monitor type is unsupported or missing target. - * @returns {Promise<{ domain: string, tld: string }>} Domain expiry support info - */ - static async findByMonitorDomainName(monitor) { - if (!(monitor.type in TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD)) { - throw new TranslatableError("domain_expiry_unsupported_monitor_type"); - } - const targetField = TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD[monitor.type]; - const target = monitor[targetField]; - if (typeof target !== "string" || target.length === 0) { - throw new TranslatableError("domain_expiry_unsupported_missing_target"); - } - - const tld = parseTld(target); - - return await DomainExpiry.findByDomainNameOrCreate(tld.domain); - } - /** * @param {string} domainName Domain name * @returns {Promise} Domain expiry bean diff --git a/test/backend-test/test-domain.js b/test/backend-test/test-domain.js index 8a6737ba6..9f774017d 100644 --- a/test/backend-test/test-domain.js +++ b/test/backend-test/test-domain.js @@ -96,7 +96,7 @@ describe("Domain Expiry", () => { }); describe("Domain Parsing", () => { - test("throws error for non-ICANN TLD (e.g. .local)", async () => { + test("throws error for non-ICANN TLD (e.g. .local)", async () => { const monitor = { type: "http", url: "https://example.local", @@ -176,18 +176,6 @@ describe("Domain Expiry", () => { }); }); - describe("findByMonitorDomainName()", () => { - test("returns DomainExpiry bean for valid monitor", async () => { - const monitor = { - type: "http", - url: "https://google.com", - }; - const bean = await DomainExpiry.findByMonitorDomainName(monitor); - assert.strictEqual(bean.domain, "google.com"); - assert.ok(bean instanceof DomainExpiry); - }); - }); - test("findByDomainNameOrCreate() retrieves expiration date for .com domain from RDAP", async () => { const domain = await DomainExpiry.findByDomainNameOrCreate("google.com"); const expiryFromRdap = await domain.getExpiryDate(); // from RDAP