6816289552
build / build (push) Successful in 1m23s
周报页新增自动发送区:管理员配置 SMTP/收件人/发送星期与小时,授权码用主密钥加密保存。 确认绑定当前草稿版本与正文哈希,正文再改则确认失效;worker 每分钟仅在启用、到点、周已结束且未发送过时发一次。 邮件同时提供渲染后的 HTML 与可读纯文本;SMTP 仅允许 TLS,拒绝明文。 迁移 000060 新增设置、确认与发送记录三张表,唯一键防重复发送。
44 lines
1.8 KiB
SQL
44 lines
1.8 KiB
SQL
-- Weekly report e-mail: operator-confirmed drafts are sent at the configured slot.
|
|
-- The SMTP password is sealed with the independently provisioned master key, never stored in clear.
|
|
create table if not exists qa_weekly_email_settings (
|
|
tenant_key text primary key,
|
|
smtp_host text not null default '',
|
|
smtp_port integer not null default 465 check (smtp_port between 1 and 65535),
|
|
smtp_username text not null default '',
|
|
smtp_password_sealed bytea,
|
|
from_address text not null default '',
|
|
recipients text[] not null default '{}',
|
|
send_weekday smallint not null default 1 check (send_weekday between 1 and 7),
|
|
send_hour smallint not null default 9 check (send_hour between 0 and 23),
|
|
enabled boolean not null default false,
|
|
revision bigint not null default 0,
|
|
updated_by text not null default '',
|
|
updated_at timestamptz not null default now()
|
|
);
|
|
|
|
create table if not exists qa_weekly_confirmations (
|
|
tenant_key text not null,
|
|
week text not null,
|
|
draft_revision bigint not null check (draft_revision > 0),
|
|
body_sha256 text not null,
|
|
confirmed_by text not null,
|
|
confirmed_at timestamptz not null default now(),
|
|
primary key (tenant_key, week)
|
|
);
|
|
|
|
create table if not exists qa_weekly_email_sends (
|
|
id uuid primary key default gen_random_uuid(),
|
|
tenant_key text not null,
|
|
week text not null,
|
|
draft_revision bigint not null,
|
|
body_sha256 text not null,
|
|
status text not null check (status in ('sending', 'sent', 'failed')),
|
|
attempts integer not null default 0,
|
|
last_error text not null default '',
|
|
message_id text not null default '',
|
|
created_at timestamptz not null default now(),
|
|
updated_at timestamptz not null default now(),
|
|
unique (tenant_key, week, draft_revision)
|
|
);
|
|
|
|
create index if not exists qa_weekly_email_sends_week_idx on qa_weekly_email_sends(tenant_key, week); |