Files
ssh-access-tui/outlook-bulk-sender/BulkArchiveMailer.Core/MailTemplateDefinition.cs
T
redlineoandClaude Sonnet 5 6e823954a3 Fix hidden add/remove template buttons, add per-template login filter
The add/remove template buttons sat directly below the fixed-height
list with only 6px of margin to the tab's bottom edge - enough on this
dev machine but not on the operator's real one (different DPI/font
scale), so the buttons rendered off the visible area. Moved them above
the list instead (visibility no longer depends on how much space is
left at the bottom) and gave the whole "Шаблоны" tab substantially
more vertical room throughout.

Also added an optional per-template login regex filter
(MailTemplateDefinition.LoginPattern): once a file's suffix matches a
template, its login must also match that template's pattern (if any)
or the row surfaces as a clear Error in the preview instead of
silently going through - addresses "непонятно что будет работать".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 12:23:54 +03:00

49 lines
2.2 KiB
C#

namespace BulkArchiveMailer.Core
{
/// <summary>
/// One configured mail template: which files it applies to (by file
/// name suffix, "{login}_{FileSuffix}.7z"), plus its Subject/BodyHtml.
/// Replaces the old fixed pair of named templates (ssh_access /
/// config_update) with an arbitrary, operator-editable list -
/// AppSettingsData.Templates now holds a List&lt;MailTemplateDefinition&gt;
/// instead of two hard-coded slots.
///
/// FileSuffix is the only identifier a template needs: it must be
/// non-empty and unique (case-insensitively) among all configured
/// templates for ArchiveScanner's suffix-to-template lookup to be
/// unambiguous. Enforcing that (non-empty + unique) is SettingsForm's
/// job at save time, not this class's - a plain data holder has no
/// validation of its own.
/// </summary>
public sealed class MailTemplateDefinition
{
public string DisplayName { get; set; } = "";
/// <summary>
/// Suffix of the file name this template renders for: matches
/// files named "{login}_{FileSuffix}.7z" (case-insensitive; see
/// FilenameParser/ArchiveScanner). Must be non-empty and unique
/// among all configured templates - see class remarks.
/// </summary>
public string FileSuffix { get; set; } = "";
public string Subject { get; set; } = "";
public string BodyHtml { get; set; } = "";
/// <summary>
/// Optional regular expression the parsed login (from
/// "{login}_{FileSuffix}.7z") must match (case-insensitively) for
/// this template to actually apply, checked by ArchiveScanner AFTER
/// the file's suffix has already matched this template. Empty (the
/// default) means "no restriction" - the original, pre-v1.2.0
/// behavior where suffix alone decides the match. Validated for
/// compilability by SettingsForm at save time; ArchiveScanner
/// itself treats an uncompilable pattern defensively as "does not
/// match" rather than throwing, in case an operator hand-edits
/// config.json with a broken regex.
/// </summary>
public string LoginPattern { get; set; } = "";
}
}