Mail relay: contract 1.6.0, the token tied to its host, IWSN in the panel

- contracts/mail-relay refreshed from IWDL 83af8c6 (1.6.0)
- an answer that is not the service's JSON is 'not confirmed' unless its status is 400 to 499
- a site with a token issued by hand does not enrol to heal: it stops and says what to ask Intecion for
- a store made on another host (a database copied to staging) is not used: the copy enrols as itself, nothing is revoked
- the panel calls the service IWSN (RELAY_SHORT_NAME); docs, logs and the doctor keep the full name

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 21:51:47 +01:00
co-authored by Claude Fable 5.2
parent 7d766b6d58
commit 0ee74ab2a4
36 changed files with 380 additions and 128 deletions
+11 -4
View File
@@ -7,7 +7,10 @@ export type RelayRefusal = {
field?: string
limit?: string
message: string
/** No usable answer came at all (time-out, connection lost): the request may have been carried out. */
/**
* No answer of the service came (time-out, connection lost, or an answer that is not its JSON with a status
* outside 400–499): the request may have been carried out.
*/
noAnswer: boolean
ok: false
reason?: string
@@ -37,8 +40,9 @@ const firstLine = (text: string) => text.split('\n')[0].slice(0, 300)
/**
* One request to the service. Never throws. An answer that is not the contract's JSON — an error page
* of the network in front, an empty or cut-off body, a redirect — is `503 unavailable`, retryable; a
* request that got no answer at all is the same with `noAnswer: true`.
* of the network in front, an empty or cut-off body, a redirect — is `unavailable`, retryable, and
* counts as no answer (`noAnswer: true`) unless its status is 400 to 499; a request that got no answer
* at all is the same with `noAnswer: true`.
*/
export async function relayRequest<T = Record<string, unknown>>(call: RelayCall): Promise<RelayAnswer<T>> {
const controller = new AbortController()
@@ -83,7 +87,10 @@ export async function relayRequest<T = Record<string, unknown>>(call: RelayCall)
...(typeof body.reason === 'string' ? { reason: body.reason } : {}),
}
}
return { code: 'unavailable', message: `The mail service answered ${status} without a usable body.`, noAnswer: false, ok: false, retryable: true, status }
// Not the service's own JSON (an error page of the network in front, an empty or cut-off body). It may be
// retried; what it says about the message depends on the status alone (contract §1): 400 to 499 — turned
// away before the service handled it; anything else, 200 included — the service may have handled it.
return { code: 'unavailable', message: `The mail service answered ${status} without a usable body.`, noAnswer: status < 400 || status > 499, ok: false, retryable: true, status }
} catch (err) {
const aborted = controller.signal.aborted
return {