E-mail: "Sending method" is an explicit choice - IWSN (built-in), Own SMTP server, Microsoft Graph (deprecated)

What is chosen is what is used. The choice is the stored field `emailMethod` of Site integrations (empty until
somebody chooses); `emailTransport` of 1.6 - 1.17.0 stays, hidden.

- no silent switch: a chosen method that cannot be used (SMTP incomplete, Graph without GRAPH_*) fails loudly
  - status smtp-incomplete / graph-not-set-up, state block, doctor mail-method - and nothing is sent another way
- upgrade writes nothing and loses no mail: until somebody chooses, the order of 1.17.0 applies and the field
  shows its result as selected; the first save of the panel's form stores the choice
- only the chosen method's fields are shown; the test e-mail names the method (Graph too)
- mail: { relay: false } does not offer "IWSN" (the stored values stay three: one SQL enum for every project)
- Postgres / SQLite: one migration (a column). Before it runs the plugin's readers read the global without the
  field, mail goes the old way, one loud log line and the doctor say what to do
- getMailMethod, setMailMethod, resolveMailMethod, readMailSettings, mailMethodColumnMissing exported
- tests on SQLite, Postgres and MongoDB, with and without the migration; docs, AGENT.md, skills, changelog

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:39:03 +01:00
co-authored by Claude Fable 5.2
parent c6841a1674
commit ee8ea42956
26 changed files with 376 additions and 138 deletions
+12
View File
@@ -82,6 +82,18 @@ test.describe('the mail service', () => {
await expect(block).toContainText(/Connected to IWSN|Połączono z IWSN/)
await expect(block).toContainText(/Left this hour: 29|Pozostało w tej godzinie: 29/)
// "Sending method": the method in effect is the one selected, and only its fields are on the page (not saved here)
const method = page.locator('#field-emailMethod')
await expect(method).toContainText(/IWSN \((built-in|wbudowany)\)/)
await expect(page.locator('#field-smtpHost')).toHaveCount(0)
await method.locator('.rs__control').click()
await page.locator('.rs__option', { hasText: /Own SMTP server|Własny serwer SMTP/ }).click()
await expect(page.locator('#field-smtpHost')).toBeVisible()
await expect(page.locator('#field-smtpUser')).toBeVisible()
await method.locator('.rs__control').click()
await page.locator('.rs__option', { hasText: /IWSN/ }).click()
await expect(page.locator('#field-smtpHost')).toHaveCount(0)
// (Payload takes the login cookie only from the site's own origin, so the request says where it comes from)
const status = await page.request.get('/api/iapl/mail-relay/status', { headers: { origin: baseURL! } })
expect(await status.json()).toMatchObject({ ok: true, relay: { connected: true, state: 'active', tokenSource: 'enrolment' }, transport: 'relay' })