Mail relay: development hosts are known by pattern, with no env - built in: *.dev.netscale.pl

The launch rule called a site non-public only when IAPL_NOINDEX was set (or the project named its hosts).
The owner's development sites set nothing, so production's database copied onto a development address
counted as a launch and would have mailed real people.

- iapl({ developmentHosts }): host patterns of development addresses. Default DEFAULT_DEVELOPMENT_HOSTS =
  ['*.dev.netscale.pl'], Intecion's own development domain; a project replaces the list or empties it.
  mail.relay.developmentHosts overrides it for the mail service.
- a site whose host matches is non-public exactly as with IAPL_NOINDEX=1; either signal is enough
- siteNonPublicSignal, matchDevelopmentHost, isDevelopmentHost, pluginDevelopmentHosts exported
- panel state: nonPublicBy, nonPublicPattern; doctor: mail-non-public (info) names the signal
- every case of the launch table runs with no env on the built-in pattern
- docs, AGENT.md, skills, changelog draft

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 10:26:12 +01:00
co-authored by Claude Fable 5.2
parent 634908eb57
commit 14abf369da
26 changed files with 319 additions and 80 deletions
+18 -6
View File
@@ -2,6 +2,7 @@ import type { BasePayload, SendEmailOptions } from 'payload'
import type { MailKind } from './kinds.js'
import { DEFAULT_DEVELOPMENT_HOSTS } from '../../shared/developmentHosts.js'
import { RELAY_BASE_URL } from './constants.js'
/**
@@ -25,9 +26,11 @@ export type RelayOptions = {
/** Calls to the public confirm route per address. Default 10 a minute. */
confirmRateLimit?: { max?: number; windowMs?: number }
/**
* Host patterns of development and preview addresses (`*` = any characters), for example
* `['*.dev.example-agency.pl']`. A site on such a host is treated as a non-public copy for `otherHosts`,
* exactly like a site with `IAPL_NOINDEX=1`. Nothing is built in: name the agency's own pattern here.
* Host patterns of development and preview addresses (`*` = any characters), for the mail service only.
* Default: the plugin's list — `iapl({ developmentHosts })`, which itself defaults to
* `DEFAULT_DEVELOPMENT_HOSTS` (`['*.dev.netscale.pl']`, Intecion's own development domain). A site on such a
* host is treated as a non-public copy for `otherHosts`, exactly like a site with `IAPL_NOINDEX=1`; no
* environment variable is needed. `[]` = no host is a development address.
*/
developmentHosts?: string[]
/**
@@ -50,7 +53,7 @@ export type RelayOptions = {
* address's entry is still there), a moved domain, or a copy of another site's database.
*
* Default (`'auto'`): by direction. A **public** site enrols by itself — launch day and a domain move need
* nobody. A **non-public** site (`IAPL_NOINDEX=1`, or a host in `developmentHosts`) that finds another
* nobody. A **non-public** site (a host in `developmentHosts`, or `IAPL_NOINDEX=1`) that finds another
* host's connection it was never told about is a copy of that site's data: it does not enrol and does not
* send by itself (it would mail real people), until an admin presses "Connect again".
*
@@ -84,7 +87,7 @@ export type RelayOptions = {
url?: string
}
export type ResolvedRelayOptions = { ownUrl: boolean; url: string } & Omit<RelayOptions, 'url'>
export type ResolvedRelayOptions = { developmentHosts: string[]; ownUrl: boolean; url: string } & Omit<RelayOptions, 'developmentHosts' | 'url'>
type PluginMail = { graphDeprecationWarning?: boolean; relay?: false | RelayOptions }
@@ -93,6 +96,15 @@ export function pluginMailOptions(payload: Pick<BasePayload, 'config'>): PluginM
return ((payload.config?.custom as { iapl?: { mail?: PluginMail } } | undefined)?.iapl?.mail ?? {})
}
/**
* The plugin's development-host patterns: `iapl({ developmentHosts })` as left in the config
* (`config.custom.iapl.developmentHosts`), else the built-in list.
*/
export function pluginDevelopmentHosts(payload: Pick<BasePayload, 'config'>): string[] {
const own = (payload.config?.custom as { iapl?: { developmentHosts?: unknown } } | undefined)?.iapl?.developmentHosts
return Array.isArray(own) ? own.filter((p): p is string => typeof p === 'string') : [...DEFAULT_DEVELOPMENT_HOSTS]
}
/**
* The options in effect: the adapter's own `relay` argument over the plugin option. `null` = the relay
* is switched off.
@@ -102,7 +114,7 @@ export function resolveRelayOptions(payload: Pick<BasePayload, 'config'>, own?:
if (own === false || (own === undefined && fromPlugin === false)) {return null}
const merged: RelayOptions = { ...(fromPlugin || {}), ...(own || {}) }
const url = (merged.url ?? RELAY_BASE_URL).replace(/\/+$/, '')
return { ...merged, ownUrl: url !== RELAY_BASE_URL, url }
return { ...merged, developmentHosts: merged.developmentHosts ?? pluginDevelopmentHosts(payload), ownUrl: url !== RELAY_BASE_URL, url }
}
const LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/