removed findByMonitorDomainName
This commit is contained in:
parent
8b38c056c6
commit
bc2136db0d
@ -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<DomainExpiry>} Domain expiry bean
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user