feat(qa): 周报邮件区分主送抄送并附统计看板图片
build / build (push) Successful in 1m21s

设置新增抄送列表,MIME 增加 Cc 头、envelope 同时投递主送与抄送,同一地址不得同时出现在两边。
确认后可保存统计看板 PNG(multipart/related + cid),发送时放在正文末尾内联显示;正文改动使确认失效后不再使用旧图。
This commit is contained in:
hermes
2026-10-26 15:59:06 +08:00
parent 600e9a2dc2
commit 822fb652ff
13 changed files with 325 additions and 25 deletions
+22
View File
@@ -6,6 +6,7 @@ export interface WeeklyMailSettings {
username: string
from: string
recipients: string[]
cc_recipients: string[]
weekday: number
hour: number
enabled: boolean
@@ -17,6 +18,7 @@ export interface WeeklyMailSettings {
export interface WeeklyMailConfirmation {
week: string
has_image: boolean
draft_revision: number
body_sha256: string
confirmed_by: string
@@ -45,6 +47,8 @@ export function parseWeeklyMailSettings(value: unknown): WeeklyMailSettings {
const v = obj(value)
const recipients = v.recipients === null ? [] : v.recipients
if (!Array.isArray(recipients) || recipients.some((item) => typeof item !== 'string')) return bad()
const cc = v.cc_recipients === null || v.cc_recipients === undefined ? [] : v.cc_recipients
if (!Array.isArray(cc) || cc.some((item) => typeof item !== 'string')) return bad()
if (typeof v.enabled !== 'boolean' || typeof v.has_password !== 'boolean') return bad()
const weekday = num(v.weekday),
hour = num(v.hour),
@@ -56,6 +60,7 @@ export function parseWeeklyMailSettings(value: unknown): WeeklyMailSettings {
username: str(v.username),
from: str(v.from),
recipients: recipients as string[],
cc_recipients: cc as string[],
weekday,
hour,
enabled: v.enabled,
@@ -77,6 +82,7 @@ export function parseWeeklyMailConfirmation(value: unknown, week: string): Weekl
confirmed_by: str(v.confirmed_by),
confirmed_at: str(v.confirmed_at),
current: v.current,
has_image: v.has_image === true,
}
}
@@ -123,6 +129,7 @@ export async function saveWeeklyMailSettings(
clear_password: form.clear_password,
from: form.from,
recipients: form.recipients,
cc_recipients: form.cc_recipients,
weekday: form.weekday,
hour: form.hour,
enabled: form.enabled,
@@ -162,3 +169,18 @@ export async function sendWeeklyMailTest(week: string): Promise<string> {
if (typeof payload.message_id !== 'string' || !payload.message_id) bad()
return payload.message_id
}
export async function uploadWeeklyMailImage(week: string, png: Blob): Promise<number> {
const buffer = await png.arrayBuffer()
let binary = ''
const bytes = new Uint8Array(buffer)
for (let index = 0; index < bytes.length; index += 0x8000)
binary += String.fromCharCode(...bytes.subarray(index, index + 0x8000))
const payload = (await getPayload(endpoint('confirmations', week) + '/image', undefined, {
method: 'POST',
headers,
body: JSON.stringify({ png_base64: btoa(binary) }),
})) as { bytes: number }
if (typeof payload.bytes !== 'number' || payload.bytes <= 0) bad()
return payload.bytes
}