Generalize mail templates from a fixed pair to an operator-managed list

ArchiveKind was a hardcoded two-value enum (ssh_access/config_update),
wired through FilenameParser's regex, MailTemplateSet's two fixed
slots, and SettingsForm's two fixed tabs. Operators wanted arbitrary
custom templates (own file-name suffix, subject, body) without a code
change per new archive kind ssh-access-tui might start producing.

Replaced with MailTemplateDefinition (DisplayName/FileSuffix/Subject/
BodyHtml) in an open-ended list: FilenameParser now accepts any
"{login}_{suffix}.7z" and ArchiveScanner matches the suffix against
the configured list; SendJob.Kind/SendLogEntry.Kind became plain
strings; SettingsForm gained a template list (+/- buttons, editor
panel) replacing the two static tabs. ssh_access/config_update are now
just the two default entries in that list, not special-cased.

Handles the two backward-compat edges that matter for a tool already
in real use: old config.json's object-shaped "templates" migrates to
the new list shape transparently on first load (DataContractJsonSerializer
turned out to silently produce an empty list rather than throw on the
old shape, so detection is structural, not exception-based), and old
send-log.csv rows with PascalCase Kind values (SshAccess/ConfigUpdate)
still dedupe correctly against the new snake_case suffixes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
redlineoandClaude Sonnet 5 committed 2026-07-24 11:26:31 +03:00
1 parent cb3b273741
commit 804b9610ca
16 files changed
+904 -288

No files matched your search

@@ -48,7 +48,7 @@
<Compile Include="ArchiveScanner.cs" />
<Compile Include="EmailAddressBuilder.cs" />
<Compile Include="FilenameParser.cs" />
<Compile Include="MailTemplates.cs" />
<Compile Include="MailTemplateDefinition.cs" />
<Compile Include="SendJob.cs" />
<Compile Include="SendLogStore.cs" />
<Compile Include="TemplateEngine.cs" />