diff --git a/src/components/editor/ContactEmailEditor.tsx b/src/components/editor/ContactEmailEditor.tsx index 97ad851..065460c 100644 --- a/src/components/editor/ContactEmailEditor.tsx +++ b/src/components/editor/ContactEmailEditor.tsx @@ -2,8 +2,28 @@ import { useTranslation } from "react-i18next"; import { ValidatedInput } from "@components/ui/ValidatedInput"; import { useEditorStore } from "@store/editor-store"; import { useSettingsStore } from "@store/settings-store"; -import { validateEmails, canAcceptEmailInput, MAX_EMAILS } from "@utils/validation"; +import { + validateEmails, + validatePurposeEmails, + canAcceptEmailInput, + MAX_EMAILS, + type ValidationResult, +} from "@utils/validation"; import { FIELD_LIMITS } from "@config/field-limits"; +import { PURPOSE_EMAIL_KEYWORDS, type PurposeEmailField } from "@config/contact-emails"; + +// Module-level so each field's validator keeps its identity across renders +// (`ValidatedInput` lists `validate` among its callback dependencies). +const PURPOSE_VALIDATORS: Record ValidationResult> = { + adEmail: (value) => validatePurposeEmails("adEmail", value), + gameKeyEmail: (value) => validatePurposeEmails("gameKeyEmail", value), + copyrightEmail: (value) => validatePurposeEmails("copyrightEmail", value), +}; + +/** The purpose words a field's help text lists — "dmca, takedown, …". */ +function keywordsOf(field: PurposeEmailField): string { + return PURPOSE_EMAIL_KEYWORDS[field].join(", "); +} /** * Contact email input(s). Two modes, driven by the `splitContactEmail` @@ -11,26 +31,31 @@ import { FIELD_LIMITS } from "@config/field-limits"; * * - off (default) — a single "Contact Email" field, exactly as before. * Feeds the description's single "📧 Business inquiries" line. - * - on — three purpose fields (general / advertising / game keys & - * playtest) that feed the grouped "📧 BUSINESS / CONTACT" block. The - * general field reuses the existing `contactEmail`, so a value entered - * before the toggle was flipped carries over as the Contact address. + * - on — the general field plus three purpose fields (advertising / game + * keys & playtest / copyright, the last added in v1.1.0) that feed the + * grouped "📧 BUSINESS / CONTACT" block. The general field reuses the + * existing `contactEmail`, so a value entered before the toggle was + * flipped carries over as the Contact address. * * Every input allows up to 3 comma-separated addresses via * {@link validateEmails}, and a malformed value never reaches the - * generated description ({@link ValidatedInput} clears it on error). + * generated description ({@link ValidatedInput} keeps it out of the store). + * The purpose fields also need a purpose word before `@` + * ({@link validatePurposeEmails}), held to the same standard. */ export function ContactEmailEditor() { const { t } = useTranslation("ui"); const contactEmail = useEditorStore((s) => s.contactEmail); const adEmail = useEditorStore((s) => s.adEmail); const gameKeyEmail = useEditorStore((s) => s.gameKeyEmail); + const copyrightEmail = useEditorStore((s) => s.copyrightEmail); const setField = useEditorStore((s) => s.set); const splitContactEmail = useSettingsStore((s) => s.splitContactEmail); - // Shared by all three fields. The cap is per field, not across the split: - // each one renders its own labelled description line, so filling the + // Shared by every field. The cap is per field, not across the split: each + // one renders its own labelled description line, so filling the // advertising address must not retroactively invalidate the contact one. + // The purpose fields pass their own `validate` *after* this spread. const emailGuard = { validate: validateEmails, // Accept the change verbatim, or reject the keystroke with `null` so the @@ -77,8 +102,9 @@ export function ContactEmailEditor() { placeholder={t("editor.adEmailPlaceholder")} value={adEmail ?? ""} onChange={(v) => setField("adEmail", v)} - helpText={t("editor.adEmailHelp")} + helpText={t("editor.adEmailHelp", { keywords: keywordsOf("adEmail") })} {...emailGuard} + validate={PURPOSE_VALIDATORS.adEmail} /> setField("gameKeyEmail", v)} - helpText={t("editor.gameKeyEmailHelp")} + helpText={t("editor.gameKeyEmailHelp", { keywords: keywordsOf("gameKeyEmail") })} {...emailGuard} + validate={PURPOSE_VALIDATORS.gameKeyEmail} + /> + setField("copyrightEmail", v)} + helpText={t("editor.copyrightEmailHelp", { keywords: keywordsOf("copyrightEmail") })} + {...emailGuard} + validate={PURPOSE_VALIDATORS.copyrightEmail} /> ); diff --git a/src/config/contact-emails.ts b/src/config/contact-emails.ts new file mode 100644 index 0000000..62aa564 --- /dev/null +++ b/src/config/contact-emails.ts @@ -0,0 +1,41 @@ +import type { EditorData } from "@store/editor-store"; + +/** + * Purpose words for the split contact emails (v1.1.0). + * + * With Settings › "Split contact email by purpose" on, every purpose-specific + * address has to say what it is for: the part before `@` must contain one of + * the field's words. Matched case-insensitively anywhere in that part, so + * `sponsorships@…`, `DMCA.team@…` and Gmail's plus-addressing + * (`name+dmca@gmail.com`) all count. The general Contact address has no rule. + * + * Shown to the user verbatim (help text and errors), in this order. + */ +export const PURPOSE_EMAIL_KEYWORDS = { + adEmail: [ + "sponsor", + "ads", + "advert", + "business", + "biz", + "partner", + "collab", + "brand", + "marketing", + "promo", + ], + gameKeyEmail: [ + "key", + "game", + "gaming", + "press", + "media", + "review", + "playtest", + "beta", + "curator", + ], + copyrightEmail: ["dmca", "takedown", "copyright", "legal", "rights", "claim"], +} as const satisfies Partial>; + +export type PurposeEmailField = keyof typeof PURPOSE_EMAIL_KEYWORDS; diff --git a/src/config/defaults.ts b/src/config/defaults.ts index 41f49b9..4f5e6f3 100644 --- a/src/config/defaults.ts +++ b/src/config/defaults.ts @@ -79,9 +79,13 @@ export interface EditorDefaults { * fields `sponsorName` / `sponsorPlatform`), and `gameKeyEmail` (game * keys & playtest invites). Each holds up to 3 comma-separated emails * (same `validateEmails` cap as `contactEmail`). Empty by default. + * v1.1.0 adds `copyrightEmail` (copyright / DMCA notices) as the fourth, + * and every purpose field needs a purpose word before `@` + * (`validatePurposeEmails`). */ adEmail: string; gameKeyEmail: string; + copyrightEmail: string; musicAttribution: string; sponsorName: string; sponsorPlatform: string; @@ -206,6 +210,7 @@ export const DEFAULTS = { contactEmail: "", adEmail: "", gameKeyEmail: "", + copyrightEmail: "", musicAttribution: "", sponsorName: "", sponsorPlatform: "", diff --git a/src/config/library-fields.ts b/src/config/library-fields.ts index b92b11f..692236b 100644 --- a/src/config/library-fields.ts +++ b/src/config/library-fields.ts @@ -14,6 +14,7 @@ export const PROFILE_FIELDS = [ "contactEmail", "adEmail", "gameKeyEmail", + "copyrightEmail", "social", "rig", "resolution", diff --git a/src/engine/description-builder.ts b/src/engine/description-builder.ts index afb44c8..01adc05 100644 --- a/src/engine/description-builder.ts +++ b/src/engine/description-builder.ts @@ -672,9 +672,11 @@ export function buildDescription( // 12. Contact. Two modes, gated by the `splitContactEmail` toggle: // • off (default) — a single "📧 Business inquiries" line, unchanged. // • on — a grouped "📧 BUSINESS / CONTACT" block with one labeled line - // per non-empty purpose field. Each line is skipped when its field - // is empty, and the whole block is skipped when all three are empty - // (same skip logic as the Community block above). + // per non-empty field: contact, advertising, game keys, copyright + // (v1.1.0). Each line is skipped when its field is empty, and the + // whole block is skipped when all four are empty (same skip logic as + // the Community block above). The purpose-word rule is the editor's + // job (`validatePurposeEmails`); this only renders. if (splitContactEmail) { const emailLines: string[] = []; if (input.contactEmail?.trim()) { @@ -686,6 +688,9 @@ export function buildDescription( if (input.gameKeyEmail?.trim()) { emailLines.push(t("description.sections.emailGameKeys", { email: input.gameKeyEmail })); } + if (input.copyrightEmail?.trim()) { + emailLines.push(t("description.sections.emailCopyright", { email: input.copyrightEmail })); + } if (emailLines.length > 0) { sections.push(`${t("description.sections.contactHeader")}\n${emailLines.join("\n")}`); } diff --git a/src/engine/types.ts b/src/engine/types.ts index 1171fdd..928dc5f 100644 --- a/src/engine/types.ts +++ b/src/engine/types.ts @@ -672,6 +672,8 @@ export interface GeneratorInput { */ adEmail?: string; gameKeyEmail?: string; + /** v1.1.0: copyright / DMCA notices — the split block's fourth line. */ + copyrightEmail?: string; /** * Music / sound attribution credit. Free-form multiline string. * When set, adds a "🎵 MUSIC / SOUND" section to the description diff --git a/src/hooks/use-current-generator-input.ts b/src/hooks/use-current-generator-input.ts index b31e9bb..adbc46d 100644 --- a/src/hooks/use-current-generator-input.ts +++ b/src/hooks/use-current-generator-input.ts @@ -60,6 +60,7 @@ export function buildGeneratorInputFromEditor( contactEmail: state.contactEmail, adEmail: state.adEmail, gameKeyEmail: state.gameKeyEmail, + copyrightEmail: state.copyrightEmail, musicAttribution: state.musicAttribution, sponsorName: state.sponsorName, sponsorPlatform: state.sponsorPlatform, diff --git a/src/i18n/locales/_schema.json b/src/i18n/locales/_schema.json index ce176e2..d9f5b29 100644 --- a/src/i18n/locales/_schema.json +++ b/src/i18n/locales/_schema.json @@ -161,6 +161,9 @@ "gameKeyEmail", "gameKeyEmailPlaceholder", "gameKeyEmailHelp", + "copyrightEmail", + "copyrightEmailPlaceholder", + "copyrightEmailHelp", "musicAttribution", "musicAttributionPlaceholder", "sponsorName", @@ -992,6 +995,7 @@ "validation": [ "emailInvalid", "emailMaxExceeded", + "emailKeywordMissing", "urlInvalid", "urlPrefixMismatch", "playlistUrlInvalid", @@ -1230,6 +1234,7 @@ "emailContact", "emailAd", "emailGameKeys", + "emailCopyright", "cta", "copyright", "usagePolicyHeader", diff --git a/src/i18n/locales/en/templates.json b/src/i18n/locales/en/templates.json index a4a4fdf..4028278 100644 --- a/src/i18n/locales/en/templates.json +++ b/src/i18n/locales/en/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 Contact: {{email}}", "emailAd": "🤝 Advertising: {{email}}", "emailGameKeys": "🎮 Game keys & playtest: {{email}}", + "emailCopyright": "©️ Copyright / DMCA: {{email}}", "cta": "👍 Like | 🔔 Subscribe | ↗️ Share", "copyright": "© {{year}} {{channelName}} — Video content only. Game, characters, music, and all related intellectual property belong to their respective owners. All rights reserved on this recording.", "usagePolicyHeader": "📋 USAGE POLICY", diff --git a/src/i18n/locales/en/ui.json b/src/i18n/locales/en/ui.json index fa28b89..b864172 100644 --- a/src/i18n/locales/en/ui.json +++ b/src/i18n/locales/en/ui.json @@ -318,10 +318,13 @@ "contactEmailPlaceholder": "business@example.com", "adEmail": "Advertising / Sponsorship Email", "adEmailPlaceholder": "sponsors@example.com", - "adEmailHelp": "Up to 3 emails, comma-separated", + "adEmailHelp": "Up to 3 emails, comma-separated. The part before @ must contain one of: {{keywords}}", "gameKeyEmail": "Game Keys & Playtest Email", "gameKeyEmailPlaceholder": "games@example.com", - "gameKeyEmailHelp": "Up to 3 emails, comma-separated", + "gameKeyEmailHelp": "Up to 3 emails, comma-separated. The part before @ must contain one of: {{keywords}}", + "copyrightEmail": "Copyright / DMCA Email", + "copyrightEmailPlaceholder": "dmca@example.com", + "copyrightEmailHelp": "Up to 3 emails, comma-separated. The part before @ must contain one of: {{keywords}}", "musicAttribution": "Music / Sound Attribution", "musicAttributionPlaceholder": "Music by Karl Casey @ White Bat Audio\nSFX from Freesound.org", "sponsorName": "Sponsor (publisher / developer)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "Show third-party advertising block in description", "thirdPartyAdsHint": "Set ad copy in your channel profile (Profiles → Edit).", "splitContactEmail": "Split contact email by purpose", - "splitContactEmailHint": "Adds Advertising and Game keys & playtest email fields, shown as a grouped block in the description.", + "splitContactEmailHint": "Adds Advertising, Game keys & playtest and Copyright email fields, shown as a grouped block in the description. Each needs a purpose word before the @ — sponsors@…, keys@…, dmca@… (with Gmail: name+dmca@gmail.com).", "showTranslationQuality": "Show translation-quality notice", "showTranslationQualityHint": "Adds an AI-translation disclaimer to descriptions generated in languages other than English and Vietnamese.", "titleFormatTitle": "Title Format", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "Range too large — generate at most {{maxSpan}} parts at once.", "emailInvalid": "Invalid email: {{email}}", "emailMaxExceeded": "Maximum {{max}} emails allowed (currently {{count}})", + "emailKeywordMissing": "{{email}}: the part before @ must contain one of: {{keywords}}", "urlInvalid": "Invalid URL. Must start with https://", "urlPrefixMismatch": "Expected URL starting with {{expected}}", "playlistUrlInvalid": "Invalid YouTube playlist URL. Expected: {{expected}}", diff --git a/src/i18n/locales/es/templates.json b/src/i18n/locales/es/templates.json index 1490829..ae18983 100644 --- a/src/i18n/locales/es/templates.json +++ b/src/i18n/locales/es/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 Contacto: {{email}}", "emailAd": "🤝 Publicidad: {{email}}", "emailGameKeys": "🎮 Claves de juego y playtest: {{email}}", + "emailCopyright": "©️ Derechos de autor / DMCA: {{email}}", "cta": "👍 Me gusta | 🔔 Suscríbete | ↗️ Comparte", "copyright": "© {{year}} {{channelName}} — Solo el contenido del vídeo. El juego, los personajes, la música y toda la propiedad intelectual relacionada pertenecen a sus respectivos propietarios. Todos los derechos reservados sobre esta grabación.", "usagePolicyHeader": "📋 POLÍTICA DE USO", diff --git a/src/i18n/locales/es/ui.json b/src/i18n/locales/es/ui.json index a9a6e73..dc33404 100644 --- a/src/i18n/locales/es/ui.json +++ b/src/i18n/locales/es/ui.json @@ -317,11 +317,14 @@ "contactEmail": "Correo de Contacto", "contactEmailPlaceholder": "negocios@ejemplo.com", "adEmail": "Email de publicidad / patrocinio", - "adEmailPlaceholder": "patrocinios@ejemplo.com", - "adEmailHelp": "Hasta 3 emails, separados por comas", + "adEmailPlaceholder": "sponsors@ejemplo.com", + "adEmailHelp": "Hasta 3 emails, separados por comas. La parte antes de @ debe contener una de: {{keywords}}", "gameKeyEmail": "Email de claves de juego y playtest", - "gameKeyEmailPlaceholder": "juegos@ejemplo.com", - "gameKeyEmailHelp": "Hasta 3 emails, separados por comas", + "gameKeyEmailPlaceholder": "games@ejemplo.com", + "gameKeyEmailHelp": "Hasta 3 emails, separados por comas. La parte antes de @ debe contener una de: {{keywords}}", + "copyrightEmail": "Email de derechos de autor / DMCA", + "copyrightEmailPlaceholder": "dmca@ejemplo.com", + "copyrightEmailHelp": "Hasta 3 emails, separados por comas. La parte antes de @ debe contener una de: {{keywords}}", "musicAttribution": "Crédito Musical / Sonidos", "musicAttributionPlaceholder": "Música: Karl Casey @ White Bat Audio\nEfectos: Freesound.org", "sponsorName": "Patrocinador (editor / desarrollador)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "Mostrar bloque de anuncios de terceros en la descripción", "thirdPartyAdsHint": "Configura el texto publicitario en el perfil del canal (Perfiles → Editar).", "splitContactEmail": "Separar el email de contacto por finalidad", - "splitContactEmailHint": "Añade campos de email de Publicidad y Claves de juego y playtest, mostrados como un bloque agrupado en la descripción.", + "splitContactEmailHint": "Añade campos de email de Publicidad, Claves de juego y playtest y Derechos de autor, mostrados como un bloque agrupado en la descripción. Cada uno necesita una palabra de propósito antes de la @ — sponsors@…, keys@…, dmca@… (con Gmail: nombre+dmca@gmail.com).", "showTranslationQuality": "Mostrar aviso de calidad de traducción", "showTranslationQualityHint": "Añade un aviso de traducción por IA a las descripciones generadas en idiomas distintos del inglés y el vietnamita.", "titleFormatTitle": "Formato del título", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "Rango demasiado grande: genera como máximo {{maxSpan}} partes a la vez.", "emailInvalid": "Email inválido: {{email}}", "emailMaxExceeded": "Máximo {{max}} emails permitidos (actualmente {{count}})", + "emailKeywordMissing": "{{email}}: la parte antes de @ debe contener una de: {{keywords}}", "urlInvalid": "URL inválida. Debe comenzar con https://", "urlPrefixMismatch": "Se espera URL que comience con {{expected}}", "playlistUrlInvalid": "URL de lista de reproducción de YouTube inválida. Se espera: {{expected}}", diff --git a/src/i18n/locales/id/templates.json b/src/i18n/locales/id/templates.json index cfacfec..b712c9f 100644 --- a/src/i18n/locales/id/templates.json +++ b/src/i18n/locales/id/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 Kontak: {{email}}", "emailAd": "🤝 Iklan: {{email}}", "emailGameKeys": "🎮 Key game & playtest: {{email}}", + "emailCopyright": "©️ Hak cipta / DMCA: {{email}}", "cta": "👍 Like | 🔔 Subscribe | ↗️ Bagikan", "copyright": "© {{year}} {{channelName}} — Hanya konten video. Game, karakter, musik, dan seluruh kekayaan intelektual terkait adalah milik pemiliknya masing-masing. Seluruh hak atas rekaman ini dilindungi.", "usagePolicyHeader": "📋 KEBIJAKAN PENGGUNAAN", diff --git a/src/i18n/locales/id/ui.json b/src/i18n/locales/id/ui.json index 8bc22ef..1e4262f 100644 --- a/src/i18n/locales/id/ui.json +++ b/src/i18n/locales/id/ui.json @@ -318,10 +318,13 @@ "contactEmailPlaceholder": "business@example.com", "adEmail": "Email Iklan / Sponsor", "adEmailPlaceholder": "sponsors@example.com", - "adEmailHelp": "Maksimal 3 email, dipisah koma", + "adEmailHelp": "Maksimal 3 email, dipisah koma. Bagian sebelum @ harus memuat salah satu: {{keywords}}", "gameKeyEmail": "Email Key Game & Playtest", "gameKeyEmailPlaceholder": "games@example.com", - "gameKeyEmailHelp": "Maksimal 3 email, dipisah koma", + "gameKeyEmailHelp": "Maksimal 3 email, dipisah koma. Bagian sebelum @ harus memuat salah satu: {{keywords}}", + "copyrightEmail": "Email Hak Cipta / DMCA", + "copyrightEmailPlaceholder": "dmca@example.com", + "copyrightEmailHelp": "Maksimal 3 email, dipisah koma. Bagian sebelum @ harus memuat salah satu: {{keywords}}", "musicAttribution": "Atribusi Musik / Suara", "musicAttributionPlaceholder": "Musik oleh Karl Casey @ White Bat Audio\nSFX dari Freesound.org", "sponsorName": "Sponsor (penerbit / pengembang)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "Tampilkan blok iklan pihak ketiga di deskripsi", "thirdPartyAdsHint": "Atur teks iklan di profil channel-mu (Profil → Ubah).", "splitContactEmail": "Pisahkan email kontak berdasarkan tujuan", - "splitContactEmailHint": "Menambahkan kolom email Iklan dan Key game & playtest, ditampilkan sebagai satu blok di deskripsi.", + "splitContactEmailHint": "Menambahkan kolom email Iklan, Key game & playtest, dan Hak cipta, ditampilkan sebagai satu blok di deskripsi. Tiap alamat butuh kata tujuan sebelum @ — sponsors@…, keys@…, dmca@… (Gmail: nama+dmca@gmail.com).", "showTranslationQuality": "Tampilkan catatan kualitas terjemahan", "showTranslationQualityHint": "Menambahkan disclaimer terjemahan AI ke deskripsi yang dibuat dalam bahasa selain Inggris dan Vietnam.", "titleFormatTitle": "Format Judul", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "Rentang terlalu besar — buat maksimal {{maxSpan}} part sekaligus.", "emailInvalid": "Email tidak valid: {{email}}", "emailMaxExceeded": "Maksimal {{max}} email (saat ini {{count}})", + "emailKeywordMissing": "{{email}}: bagian sebelum @ harus memuat salah satu: {{keywords}}", "urlInvalid": "URL tidak valid. Harus diawali https://", "urlPrefixMismatch": "Diharapkan URL yang diawali {{expected}}", "playlistUrlInvalid": "URL playlist YouTube tidak valid. Diharapkan: {{expected}}", diff --git a/src/i18n/locales/ja/templates.json b/src/i18n/locales/ja/templates.json index 4af2d49..10255f8 100644 --- a/src/i18n/locales/ja/templates.json +++ b/src/i18n/locales/ja/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 連絡先:{{email}}", "emailAd": "🤝 広告:{{email}}", "emailGameKeys": "🎮 ゲームキー・プレイテスト:{{email}}", + "emailCopyright": "©️ 著作権・DMCA:{{email}}", "cta": "👍 いいね | 🔔 チャンネル登録 | ↗️ シェア", "copyright": "© {{year}} {{channelName}} — 動画コンテンツのみ。ゲーム、キャラクター、音楽、関連する知的財産はすべて各権利者に帰属します。本録画物の全権利は留保されます。", "usagePolicyHeader": "📋 動画利用ポリシー", diff --git a/src/i18n/locales/ja/ui.json b/src/i18n/locales/ja/ui.json index 7f8a0db..90a39f1 100644 --- a/src/i18n/locales/ja/ui.json +++ b/src/i18n/locales/ja/ui.json @@ -318,10 +318,13 @@ "contactEmailPlaceholder": "business@example.com", "adEmail": "広告・スポンサー用メール", "adEmailPlaceholder": "sponsors@example.com", - "adEmailHelp": "最大3つのメール、カンマ区切り", + "adEmailHelp": "最大3つのメール、カンマ区切り。@ の前に次のいずれかを含めてください:{{keywords}}", "gameKeyEmail": "ゲームキー・プレイテスト用メール", "gameKeyEmailPlaceholder": "games@example.com", - "gameKeyEmailHelp": "最大3つのメール、カンマ区切り", + "gameKeyEmailHelp": "最大3つのメール、カンマ区切り。@ の前に次のいずれかを含めてください:{{keywords}}", + "copyrightEmail": "著作権・DMCA 用メール", + "copyrightEmailPlaceholder": "dmca@example.com", + "copyrightEmailHelp": "最大3つのメール、カンマ区切り。@ の前に次のいずれかを含めてください:{{keywords}}", "musicAttribution": "音楽・サウンドクレジット", "musicAttributionPlaceholder": "音楽: Karl Casey @ White Bat Audio\n効果音: Freesound.org", "sponsorName": "スポンサー (パブリッシャー / デベロッパー)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "説明欄にサードパーティ広告ブロックを表示", "thirdPartyAdsHint": "広告コピーはチャンネルプロフィールに設定してください (プロフィール → 編集)。", "splitContactEmail": "連絡先メールを用途別に分ける", - "splitContactEmailHint": "広告用とゲームキー・プレイテスト用のメール欄を追加し、説明欄にまとめて表示します。", + "splitContactEmailHint": "広告用、ゲームキー・プレイテスト用、著作権用のメール欄を追加し、説明欄にまとめて表示します。各アドレスは @ の前に用途を示す語が必要です — sponsors@…、keys@…、dmca@…(Gmail なら name+dmca@gmail.com)。", "showTranslationQuality": "翻訳品質の注記を表示", "showTranslationQualityHint": "英語とベトナム語以外の言語で生成した説明にAI翻訳の注記を追加します。", "titleFormatTitle": "タイトル書式", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "範囲が大きすぎます — 一度に生成できるのは最大{{maxSpan}}パートまでです。", "emailInvalid": "無効なメール: {{email}}", "emailMaxExceeded": "最大{{max}}件のメール (現在{{count}}件)", + "emailKeywordMissing": "{{email}}:@ の前に次のいずれかが必要です:{{keywords}}", "urlInvalid": "無効なURL。https://で始める必要があります", "urlPrefixMismatch": "{{expected}}で始まるURLが必要です", "playlistUrlInvalid": "無効なYouTubeプレイリストURLです。期待される形式: {{expected}}", diff --git a/src/i18n/locales/ko/templates.json b/src/i18n/locales/ko/templates.json index e03eee6..eafa285 100644 --- a/src/i18n/locales/ko/templates.json +++ b/src/i18n/locales/ko/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 연락처: {{email}}", "emailAd": "🤝 광고: {{email}}", "emailGameKeys": "🎮 게임 키 & 플레이테스트: {{email}}", + "emailCopyright": "©️ 저작권 / DMCA: {{email}}", "cta": "👍 좋아요 | 🔔 구독 | ↗️ 공유", "copyright": "© {{year}} {{channelName}} — 영상 콘텐츠에 한함. 게임, 캐릭터, 음악 및 관련 지식재산권은 각 권리자에게 귀속됩니다. 본 녹화물의 모든 권리를 보유합니다.", "usagePolicyHeader": "📋 영상 사용 정책", diff --git a/src/i18n/locales/ko/ui.json b/src/i18n/locales/ko/ui.json index a3f138a..a1f0470 100644 --- a/src/i18n/locales/ko/ui.json +++ b/src/i18n/locales/ko/ui.json @@ -318,10 +318,13 @@ "contactEmailPlaceholder": "business@example.com", "adEmail": "광고 / 협찬 이메일", "adEmailPlaceholder": "sponsors@example.com", - "adEmailHelp": "최대 3개 이메일, 쉼표로 구분", + "adEmailHelp": "최대 3개 이메일, 쉼표로 구분. @ 앞부분에 다음 중 하나가 있어야 합니다: {{keywords}}", "gameKeyEmail": "게임 키 & 플레이테스트 이메일", "gameKeyEmailPlaceholder": "games@example.com", - "gameKeyEmailHelp": "최대 3개 이메일, 쉼표로 구분", + "gameKeyEmailHelp": "최대 3개 이메일, 쉼표로 구분. @ 앞부분에 다음 중 하나가 있어야 합니다: {{keywords}}", + "copyrightEmail": "저작권 / DMCA 이메일", + "copyrightEmailPlaceholder": "dmca@example.com", + "copyrightEmailHelp": "최대 3개 이메일, 쉼표로 구분. @ 앞부분에 다음 중 하나가 있어야 합니다: {{keywords}}", "musicAttribution": "음악 / 사운드 크레딧", "musicAttributionPlaceholder": "음악: Karl Casey @ White Bat Audio\n효과음: Freesound.org", "sponsorName": "스폰서 (퍼블리셔 / 개발사)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "설명란에 써드파티 광고 블록 표시", "thirdPartyAdsHint": "광고 문구는 채널 프로필에 입력하세요 (프로필 → 편집).", "splitContactEmail": "연락처 이메일을 용도별로 분리", - "splitContactEmailHint": "광고 및 게임 키 & 플레이테스트 이메일 필드를 추가하고 설명란에 묶음 블록으로 표시합니다.", + "splitContactEmailHint": "광고, 게임 키 & 플레이테스트, 저작권 이메일 필드를 추가하고 설명란에 묶음 블록으로 표시합니다. 각 주소는 @ 앞에 용도를 나타내는 단어가 필요합니다 — sponsors@…, keys@…, dmca@… (Gmail: name+dmca@gmail.com).", "showTranslationQuality": "번역 품질 안내 표시", "showTranslationQualityHint": "영어와 베트남어 외의 언어로 생성된 설명에 AI 번역 안내를 추가합니다.", "titleFormatTitle": "제목 형식", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "범위가 너무 큽니다 — 한 번에 최대 {{maxSpan}}개 파트까지 생성할 수 있습니다.", "emailInvalid": "잘못된 이메일: {{email}}", "emailMaxExceeded": "최대 {{max}}개 이메일 허용 (현재 {{count}}개)", + "emailKeywordMissing": "{{email}}: @ 앞부분에 다음 중 하나가 있어야 합니다: {{keywords}}", "urlInvalid": "잘못된 URL입니다. https://로 시작해야 합니다", "urlPrefixMismatch": "{{expected}}로 시작하는 URL이 필요합니다", "playlistUrlInvalid": "잘못된 YouTube 재생목록 URL입니다. 예상 형식: {{expected}}", diff --git a/src/i18n/locales/pt-BR/templates.json b/src/i18n/locales/pt-BR/templates.json index 1452b3d..6e8b990 100644 --- a/src/i18n/locales/pt-BR/templates.json +++ b/src/i18n/locales/pt-BR/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 Contato: {{email}}", "emailAd": "🤝 Publicidade: {{email}}", "emailGameKeys": "🎮 Chaves de jogo & playtest: {{email}}", + "emailCopyright": "©️ Direitos autorais / DMCA: {{email}}", "cta": "👍 Curte | 🔔 Inscreve-se | ↗️ Compartilha", "copyright": "© {{year}} {{channelName}} — Apenas o conteúdo do vídeo. O jogo, personagens, música e toda a propriedade intelectual relacionada pertencem aos seus respectivos donos. Todos os direitos reservados sobre esta gravação.", "usagePolicyHeader": "📋 POLÍTICA DE USO", diff --git a/src/i18n/locales/pt-BR/ui.json b/src/i18n/locales/pt-BR/ui.json index 397746a..91aaddd 100644 --- a/src/i18n/locales/pt-BR/ui.json +++ b/src/i18n/locales/pt-BR/ui.json @@ -318,10 +318,13 @@ "contactEmailPlaceholder": "business@example.com", "adEmail": "E-mail de publicidade / patrocínio", "adEmailPlaceholder": "sponsors@example.com", - "adEmailHelp": "Até 3 e-mails, separados por vírgula", + "adEmailHelp": "Até 3 e-mails, separados por vírgula. A parte antes do @ deve conter uma destas: {{keywords}}", "gameKeyEmail": "E-mail de chaves de jogo e playtest", "gameKeyEmailPlaceholder": "games@example.com", - "gameKeyEmailHelp": "Até 3 e-mails, separados por vírgula", + "gameKeyEmailHelp": "Até 3 e-mails, separados por vírgula. A parte antes do @ deve conter uma destas: {{keywords}}", + "copyrightEmail": "E-mail de direitos autorais / DMCA", + "copyrightEmailPlaceholder": "dmca@example.com", + "copyrightEmailHelp": "Até 3 e-mails, separados por vírgula. A parte antes do @ deve conter uma destas: {{keywords}}", "musicAttribution": "Créditos de música / som", "musicAttributionPlaceholder": "Música de Karl Casey @ White Bat Audio\nEfeitos sonoros do Freesound.org", "sponsorName": "Patrocinador (publisher / desenvolvedora)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "Mostrar bloco de publicidade de terceiros na descrição", "thirdPartyAdsHint": "Defina o texto do anúncio no perfil do seu canal (Perfis → Editar).", "splitContactEmail": "Separar e-mail de contato por finalidade", - "splitContactEmailHint": "Adiciona os campos de e-mail de Publicidade e de Chaves de jogo & playtest, exibidos como um bloco agrupado na descrição.", + "splitContactEmailHint": "Adiciona os campos de e-mail de Publicidade, Chaves de jogo & playtest e Direitos autorais, exibidos como um bloco agrupado na descrição. Cada um precisa de uma palavra de finalidade antes do @ — sponsors@…, keys@…, dmca@… (no Gmail: nome+dmca@gmail.com).", "showTranslationQuality": "Mostrar aviso sobre a qualidade da tradução", "showTranslationQualityHint": "Adiciona um aviso de tradução por IA às descrições geradas em idiomas que não sejam inglês e vietnamita.", "titleFormatTitle": "Formato do título", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "Intervalo grande demais — gere no máximo {{maxSpan}} partes de uma vez.", "emailInvalid": "E-mail inválido: {{email}}", "emailMaxExceeded": "Máximo de {{max}} e-mails permitidos (atualmente {{count}})", + "emailKeywordMissing": "{{email}}: a parte antes do @ deve conter uma destas: {{keywords}}", "urlInvalid": "URL inválida. Precisa começar com https://", "urlPrefixMismatch": "Esperado uma URL começando com {{expected}}", "playlistUrlInvalid": "URL de playlist do YouTube inválida. Esperado: {{expected}}", diff --git a/src/i18n/locales/vi/templates.json b/src/i18n/locales/vi/templates.json index cdb2b0e..16c063d 100644 --- a/src/i18n/locales/vi/templates.json +++ b/src/i18n/locales/vi/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 Liên hệ: {{email}}", "emailAd": "🤝 Quảng cáo: {{email}}", "emailGameKeys": "🎮 Key game & mời playtest: {{email}}", + "emailCopyright": "©️ Bản quyền / DMCA: {{email}}", "cta": "👍 Like | 🔔 Đăng ký | ↗️ Chia sẻ", "copyright": "© {{year}} {{channelName}} — Bản quyền chỉ áp dụng cho nội dung video. Game, nhân vật, âm nhạc và mọi tài sản trí tuệ liên quan thuộc về chủ sở hữu tương ứng. Mọi quyền được bảo lưu với bản ghi này.", "usagePolicyHeader": "📋 ĐIỀU KIỆN DÙNG VIDEO", diff --git a/src/i18n/locales/vi/ui.json b/src/i18n/locales/vi/ui.json index d41d6db..a1b4b09 100644 --- a/src/i18n/locales/vi/ui.json +++ b/src/i18n/locales/vi/ui.json @@ -318,10 +318,13 @@ "contactEmailPlaceholder": "business@example.com", "adEmail": "Email quảng cáo / tài trợ", "adEmailPlaceholder": "sponsors@example.com", - "adEmailHelp": "Tối đa 3 email, cách nhau bằng dấu phẩy", + "adEmailHelp": "Tối đa 3 email, cách nhau bằng dấu phẩy. Phần trước @ phải chứa một trong các từ: {{keywords}}", "gameKeyEmail": "Email key game & mời playtest", "gameKeyEmailPlaceholder": "games@example.com", - "gameKeyEmailHelp": "Tối đa 3 email, cách nhau bằng dấu phẩy", + "gameKeyEmailHelp": "Tối đa 3 email, cách nhau bằng dấu phẩy. Phần trước @ phải chứa một trong các từ: {{keywords}}", + "copyrightEmail": "Email bản quyền / DMCA", + "copyrightEmailPlaceholder": "dmca@example.com", + "copyrightEmailHelp": "Tối đa 3 email, cách nhau bằng dấu phẩy. Phần trước @ phải chứa một trong các từ: {{keywords}}", "musicAttribution": "Credit nhạc / âm thanh", "musicAttributionPlaceholder": "Nhạc: Karl Casey @ White Bat Audio\nSFX: Freesound.org", "sponsorName": "Sponsor (publisher / developer)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "Hiện block quảng cáo bên thứ 3 trong description", "thirdPartyAdsHint": "Nhập nội dung quảng cáo trong Hồ sơ kênh (Profiles → Sửa).", "splitContactEmail": "Tách email liên hệ theo mục đích", - "splitContactEmailHint": "Thêm ô email Quảng cáo và Key game & mời playtest, hiển thị thành một khối gộp trong phần mô tả.", + "splitContactEmailHint": "Thêm ô email Quảng cáo, Key game & mời playtest và Bản quyền, hiển thị thành một khối gộp trong phần mô tả. Mỗi ô cần một từ chỉ mục đích trước @ — sponsors@…, keys@…, dmca@… (Gmail: ten+dmca@gmail.com).", "showTranslationQuality": "Hiện ghi chú chất lượng bản dịch", "showTranslationQualityHint": "Thêm ghi chú về dịch thuật bằng AI vào mô tả ở các ngôn ngữ khác ngoài tiếng Anh và tiếng Việt.", "titleFormatTitle": "Định dạng tiêu đề", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "Khoảng quá lớn — chỉ tạo tối đa {{maxSpan}} phần mỗi lần.", "emailInvalid": "Email không hợp lệ: {{email}}", "emailMaxExceeded": "Tối đa {{max}} email (hiện tại {{count}})", + "emailKeywordMissing": "{{email}}: phần trước @ phải chứa một trong các từ: {{keywords}}", "urlInvalid": "URL không hợp lệ. Phải bắt đầu bằng https://", "urlPrefixMismatch": "URL nên bắt đầu bằng {{expected}}", "playlistUrlInvalid": "URL playlist YouTube không hợp lệ. Định dạng mong muốn: {{expected}}", diff --git a/src/i18n/locales/zh/templates.json b/src/i18n/locales/zh/templates.json index 869cc05..c6ae828 100644 --- a/src/i18n/locales/zh/templates.json +++ b/src/i18n/locales/zh/templates.json @@ -127,6 +127,7 @@ "emailContact": "📧 联系:{{email}}", "emailAd": "🤝 广告:{{email}}", "emailGameKeys": "🎮 游戏密钥 & 试玩:{{email}}", + "emailCopyright": "©️ 版权 / DMCA:{{email}}", "cta": "👍 点赞 | 🔔 订阅 | ↗️ 分享", "copyright": "© {{year}} {{channelName}} — 仅限视频内容。游戏、角色、音乐及相关知识产权归各自所有者所有。保留本录像的所有权利。", "usagePolicyHeader": "📋 视频使用规则", diff --git a/src/i18n/locales/zh/ui.json b/src/i18n/locales/zh/ui.json index 8e1021f..8e269a5 100644 --- a/src/i18n/locales/zh/ui.json +++ b/src/i18n/locales/zh/ui.json @@ -318,10 +318,13 @@ "contactEmailPlaceholder": "business@example.com", "adEmail": "广告 / 赞助邮箱", "adEmailPlaceholder": "sponsors@example.com", - "adEmailHelp": "最多3个邮箱,用逗号分隔", + "adEmailHelp": "最多3个邮箱,用逗号分隔。@ 前面必须包含以下之一:{{keywords}}", "gameKeyEmail": "游戏密钥 & 试玩邀请邮箱", "gameKeyEmailPlaceholder": "games@example.com", - "gameKeyEmailHelp": "最多3个邮箱,用逗号分隔", + "gameKeyEmailHelp": "最多3个邮箱,用逗号分隔。@ 前面必须包含以下之一:{{keywords}}", + "copyrightEmail": "版权 / DMCA 邮箱", + "copyrightEmailPlaceholder": "dmca@example.com", + "copyrightEmailHelp": "最多3个邮箱,用逗号分隔。@ 前面必须包含以下之一:{{keywords}}", "musicAttribution": "音乐 / 音效署名", "musicAttributionPlaceholder": "音乐:Karl Casey @ White Bat Audio\n音效:Freesound.org", "sponsorName": "赞助商 (发行商 / 开发商)", @@ -1122,7 +1125,7 @@ "showThirdPartyAds": "在描述中显示第三方广告区块", "thirdPartyAdsHint": "广告文案请在频道配置中设置(配置文件 → 编辑)。", "splitContactEmail": "按用途拆分联系邮箱", - "splitContactEmailHint": "添加广告和游戏密钥 & 试玩邮箱字段,在描述中以分组区块显示。", + "splitContactEmailHint": "添加广告、游戏密钥 & 试玩和版权邮箱字段,在描述中以分组区块显示。每个地址的 @ 前面需要包含用途词 — sponsors@…、keys@…、dmca@…(Gmail 可用 name+dmca@gmail.com)。", "showTranslationQuality": "显示翻译质量提示", "showTranslationQualityHint": "为以英语和越南语以外语言生成的简介添加 AI 翻译说明。", "titleFormatTitle": "标题格式", @@ -1217,6 +1220,7 @@ "rangeTooLarge": "范围太大 — 每次最多生成 {{maxSpan}} 个分集。", "emailInvalid": "无效邮箱: {{email}}", "emailMaxExceeded": "最多允许{{max}}个邮箱 (当前{{count}}个)", + "emailKeywordMissing": "{{email}}:@ 前面必须包含以下之一:{{keywords}}", "urlInvalid": "无效URL。必须以https://开头", "urlPrefixMismatch": "URL应以{{expected}}开头", "playlistUrlInvalid": "无效的YouTube播放列表URL。期望格式: {{expected}}", diff --git a/src/store/editor-store.ts b/src/store/editor-store.ts index 45baf27..6e53eaf 100644 --- a/src/store/editor-store.ts +++ b/src/store/editor-store.ts @@ -97,6 +97,10 @@ export interface EditorData { * `sponsorName`); `gameKeyEmail` = game keys & playtest invites. */ adEmail: string; gameKeyEmail: string; + /** v1.1.0: copyright / DMCA / takedown notices — the fourth split line. + * Like the other two purpose fields, its addresses must carry a purpose + * word before `@` (`PURPOSE_EMAIL_KEYWORDS`). */ + copyrightEmail: string; musicAttribution: string; sponsorName: string; sponsorPlatform: string; @@ -316,6 +320,7 @@ export const PATCH_FIELD_LIMITS: Partial> = { contactEmail: FIELD_LIMITS.EMAIL_FIELD, adEmail: FIELD_LIMITS.EMAIL_FIELD, gameKeyEmail: FIELD_LIMITS.EMAIL_FIELD, + copyrightEmail: FIELD_LIMITS.EMAIL_FIELD, playlistLink: FIELD_LIMITS.URL, playtestLink: FIELD_LIMITS.URL, messengerCommunityLink: FIELD_LIMITS.URL, @@ -411,6 +416,7 @@ const initialState: EditorData = { contactEmail: DEFAULTS.editor.contactEmail, adEmail: DEFAULTS.editor.adEmail, gameKeyEmail: DEFAULTS.editor.gameKeyEmail, + copyrightEmail: DEFAULTS.editor.copyrightEmail, musicAttribution: DEFAULTS.editor.musicAttribution, sponsorName: DEFAULTS.editor.sponsorName, sponsorPlatform: DEFAULTS.editor.sponsorPlatform, @@ -475,7 +481,7 @@ export function editorDataOf(state: EditorData): EditorData { * Bump together with a new step in {@link migrateEditorState}; backups * record this number so an import can run the steps a draft still needs. */ -export const EDITOR_STORE_VERSION = 19; +export const EDITOR_STORE_VERSION = 20; export const useEditorStore = create()( persist( @@ -618,6 +624,15 @@ export const useEditorStore = create()( // settings toggle is on. Additive: both back-fill to "". // Non-string values coerce to "". The existing `contactEmail` // is reused as the general-contact line, so no data moves. + // v18 → v19: v1.0.0. GPU catalog — `rig.gpu` moves from + // `brand|series|model` to `gpu:` (or the card's full name + // as the user's own text when it isn't in the catalog). + // v19 → v20: v1.1.0. `copyrightEmail` (copyright / DMCA notices) + // joined the split contact block as its fourth line. + // Additive: back-fills to "", non-string values coerce to "". + // Saved `adEmail` / `gameKeyEmail` values are left as they + // are even when they lack a purpose word — Strict Mode points + // at them instead of a migration deleting the user's data. version: EDITOR_STORE_VERSION, migrate: (persistedState, version) => migrateEditorState(persistedState, version), partialize: (state) => editorDataOf(state), @@ -889,6 +904,10 @@ export function migrateEditorState(persistedState: unknown, version: number): Ed // name as the user's own text when the card isn't in the catalog). state.rig = migrateRig(state.rig); } + if (version < 20) { + // v1.1.0 copyright email. Additive back-fill + defensive coercion. + if (typeof state.copyrightEmail !== "string") state.copyrightEmail = ""; + } return { ...initialState, ...state } as EditorData; } diff --git a/src/store/profile-store.ts b/src/store/profile-store.ts index da1b7c3..3040cd3 100644 --- a/src/store/profile-store.ts +++ b/src/store/profile-store.ts @@ -18,7 +18,8 @@ import type { GraphicsPreset } from "@config/graphics-settings"; * (back-filled by the migrations below). v1.0.0 added the Vietnamese * donate fields, the community invite links and `graphicsPresetCustom` — * optional, because profiles saved before then don't have them and - * applying one must leave those editor fields alone. + * applying one must leave those editor fields alone. v1.1.0's + * `copyrightEmail` is optional for the same reason. */ export interface Profile { id: string; @@ -27,6 +28,7 @@ export interface Profile { contactEmail: string; adEmail: string; gameKeyEmail: string; + copyrightEmail?: string; social: Record; rig: Record; resolution: string; diff --git a/src/utils/editor-issues.ts b/src/utils/editor-issues.ts index e03ad35..4d696f7 100644 --- a/src/utils/editor-issues.ts +++ b/src/utils/editor-issues.ts @@ -4,6 +4,7 @@ import { SOCIAL_FIELDS } from "@config/social-fields"; import { PLAYTEST_PLATFORMS } from "@config/playtest-platforms"; import { validateEmails, + validatePurposeEmails, validateUrl, validateUrlWithPattern, validateUrlWithPrefix, @@ -58,7 +59,10 @@ export interface EditorIssue { /** Context that decides which optional fields are actually in play. */ export interface EditorIssueContext { - /** When false, `adEmail` / `gameKeyEmail` are not rendered, so they cannot block. */ + /** + * When false, `adEmail` / `gameKeyEmail` / `copyrightEmail` are not + * rendered, so they cannot block. + */ splitContactEmail: boolean; /** Output language — Zalo is Vietnamese-only. */ language: string; @@ -73,7 +77,9 @@ export interface EditorIssueContext { * becomes an unresolvable dead end. */ export function isRelevantIssueId(id: string, context: EditorIssueContext): boolean { - if (id === "adEmail" || id === "gameKeyEmail") return context.splitContactEmail; + if (id === "adEmail" || id === "gameKeyEmail" || id === "copyrightEmail") { + return context.splitContactEmail; + } if (id === "zaloGroupLink") return context.language === "vi"; return true; } @@ -153,14 +159,16 @@ export function collectEditorIssues( if (isRelevantIssueId("zaloGroupLink", context) && editor.zaloGroupLink) add("zaloGroupLink", "editor.zaloGroupLink", validateZaloGroupUrl(editor.zaloGroupLink)); - // Contact emails. The two purpose-specific fields only exist — and only - // render — while the split toggle is on. + // Contact emails. The three purpose-specific fields only exist — and only + // render — while the split toggle is on, and each needs a purpose word + // before `@` (v1.1.0). A value saved before that rule existed is flagged + // here, never rewritten. if (editor.contactEmail) add("contactEmail", "editor.contactEmail", validateEmails(editor.contactEmail)); if (splitContactEmail) { - if (editor.adEmail) add("adEmail", "editor.adEmail", validateEmails(editor.adEmail)); - if (editor.gameKeyEmail) - add("gameKeyEmail", "editor.gameKeyEmail", validateEmails(editor.gameKeyEmail)); + for (const field of ["adEmail", "gameKeyEmail", "copyrightEmail"] as const) { + if (editor[field]) add(field, `editor.${field}`, validatePurposeEmails(field, editor[field])); + } } if (editor.playlistLink) diff --git a/src/utils/validation.ts b/src/utils/validation.ts index 2856cc1..4e2217d 100644 --- a/src/utils/validation.ts +++ b/src/utils/validation.ts @@ -1,3 +1,5 @@ +import { PURPOSE_EMAIL_KEYWORDS, type PurposeEmailField } from "@config/contact-emails"; + // The domain must have a dot and a letters-only TLD: "name@localhost" or // "name@gmail" are typos in a description, not addresses (v1.0.0). const EMAIL_REGEX = @@ -8,6 +10,14 @@ const URL_REGEX = export const MAX_EMAILS = 3; +/** The addresses in a comma-separated email field, trimmed, empties dropped. */ +function emailSegments(input: string): string[] { + return input + .split(",") + .map((e) => e.trim()) + .filter(Boolean); +} + /** * How many addresses a comma-separated email field currently holds. * @@ -17,10 +27,7 @@ export const MAX_EMAILS = 3; * has exactly one answer. */ export function countEmailSegments(input: string): number { - return input - .split(",") - .map((e) => e.trim()) - .filter(Boolean).length; + return emailSegments(input).length; } /** @@ -50,10 +57,7 @@ export function validateEmails(input: string): ValidationResult { const trimmed = input.trim(); if (!trimmed) return { valid: true }; - const emails = trimmed - .split(",") - .map((e) => e.trim()) - .filter(Boolean); + const emails = emailSegments(trimmed); // Still enforced here as well as at the input: `canAcceptEmailInput` guards // typing, but a value can also arrive from a profile / preset / template @@ -79,6 +83,33 @@ export function validateEmails(input: string): ValidationResult { return { valid: true }; } +/** + * {@link validateEmails}, plus the rule for the split contact fields (v1.1.0): + * the part before `@` of every address must contain one of the field's + * {@link PURPOSE_EMAIL_KEYWORDS} — case-insensitive, anywhere in it, so + * `name+dmca@gmail.com` counts. A missing word is an error like a malformed + * address: the value is not saved and Strict Mode blocks. + */ +export function validatePurposeEmails(field: PurposeEmailField, input: string): ValidationResult { + const result = validateEmails(input); + if (!result.valid) return result; + + const keywords: readonly string[] = PURPOSE_EMAIL_KEYWORDS[field]; + for (const email of emailSegments(input)) { + // Past EMAIL_REGEX, which allows no "@" in either part — so exactly one. + const localPart = email.slice(0, email.indexOf("@")).toLowerCase(); + if (!keywords.some((word) => localPart.includes(word))) { + return { + valid: false, + error: "validation.emailKeywordMissing", + errorParams: { email, keywords: keywords.join(", ") }, + }; + } + } + + return result; +} + export function validateUrl(input: string): ValidationResult { const trimmed = input.trim(); if (!trimmed) return { valid: true }; diff --git a/tests/engine/description-builder.test.ts b/tests/engine/description-builder.test.ts index 671cbe2..f95e5e0 100644 --- a/tests/engine/description-builder.test.ts +++ b/tests/engine/description-builder.test.ts @@ -1066,16 +1066,53 @@ describe("buildDescription", () => { expect(result).not.toContain("Advertising:"); }); - it("omits the whole block when all three fields are empty", () => { + it("omits the whole block when all four fields are empty", () => { const t = createMockT("en"); const result = buildDescription( - makeInput({ contactEmail: "", adEmail: "", gameKeyEmail: "" }), + makeInput({ contactEmail: "", adEmail: "", gameKeyEmail: "", copyrightEmail: "" }), t, { splitContactEmail: true }, ); expect(result).not.toContain("BUSINESS / CONTACT"); expect(result).not.toContain("Business inquiries:"); }); + + it("adds the copyright line last in the block (v1.1.0)", () => { + const t = createMockT("en"); + const result = buildDescription( + makeInput({ + contactEmail: "contact@example.com", + adEmail: "ads@example.com", + gameKeyEmail: "games@example.com", + copyrightEmail: "dmca@example.com", + }), + t, + { splitContactEmail: true }, + ); + expect(result).toContain( + [ + "📧 BUSINESS / CONTACT", + "📧 Contact: contact@example.com", + "🤝 Advertising: ads@example.com", + "🎮 Game keys & playtest: games@example.com", + "©️ Copyright / DMCA: dmca@example.com", + ].join("\n"), + ); + }); + + it("renders the block for a copyright address alone", () => { + const t = createMockT("vi"); + const result = buildDescription(makeInput({ copyrightEmail: "kenh+dmca@gmail.com" }), t, { + splitContactEmail: true, + }); + expect(result).toContain("📧 LIÊN HỆ CÔNG VIỆC\n©️ Bản quyền / DMCA: kenh+dmca@gmail.com"); + }); + + it("ignores the copyright address while the toggle is off", () => { + const t = createMockT("en"); + const result = buildDescription(makeInput({ copyrightEmail: "dmca@example.com" }), t); + expect(result).not.toContain("dmca@example.com"); + }); }); it("generates part description correctly", () => { diff --git a/tests/hooks/generator-input-mapping.test.ts b/tests/hooks/generator-input-mapping.test.ts index 88ed35d..b3be522 100644 --- a/tests/hooks/generator-input-mapping.test.ts +++ b/tests/hooks/generator-input-mapping.test.ts @@ -77,6 +77,7 @@ function makeEditorData(overrides: Partial = {}): EditorData { contactEmail: DEFAULTS.editor.contactEmail, adEmail: DEFAULTS.editor.adEmail, gameKeyEmail: DEFAULTS.editor.gameKeyEmail, + copyrightEmail: DEFAULTS.editor.copyrightEmail, musicAttribution: DEFAULTS.editor.musicAttribution, sponsorName: DEFAULTS.editor.sponsorName, sponsorPlatform: DEFAULTS.editor.sponsorPlatform, diff --git a/tests/store/editor-store.migrate.test.ts b/tests/store/editor-store.migrate.test.ts index c458de1..8ba2497 100644 --- a/tests/store/editor-store.migrate.test.ts +++ b/tests/store/editor-store.migrate.test.ts @@ -426,3 +426,41 @@ describe("migrateEditorState — v18 → v19 (v1.0.0 GPU catalog)", () => { expect(migrateEditorState({ rig }, 19).rig).toEqual(rig); }); }); + +describe("migrateEditorState — v19 → v20 (v1.1.0 copyright email)", () => { + // Route v9 through every prior migration, then strip the v20 key so the + // v20 block is what supplies it. + function makeV19Persisted(overrides: Record = {}): Record { + const full = migrateEditorState(makeV9Persisted(), 9) as unknown as Record; + delete full.copyrightEmail; + return { ...full, ...overrides }; + } + + it("back-fills copyrightEmail with an empty string", () => { + expect(migrateEditorState(makeV19Persisted(), 19).copyrightEmail).toBe(""); + }); + + it("coerces a non-string persisted value to an empty string", () => { + expect(migrateEditorState(makeV19Persisted({ copyrightEmail: 42 }), 19).copyrightEmail).toBe( + "", + ); + expect(migrateEditorState(makeV19Persisted({ copyrightEmail: null }), 19).copyrightEmail).toBe( + "", + ); + }); + + it("preserves a valid persisted value", () => { + const result = migrateEditorState(makeV19Persisted({ copyrightEmail: "dmca@example.com" }), 19); + expect(result.copyrightEmail).toBe("dmca@example.com"); + }); + + it("leaves saved purpose emails alone, even without a purpose word", () => { + // Strict Mode flags these; a migration must never delete the user's data. + const result = migrateEditorState( + makeV19Persisted({ adEmail: "hello@channel.com", gameKeyEmail: "me@channel.com" }), + 19, + ); + expect(result.adEmail).toBe("hello@channel.com"); + expect(result.gameKeyEmail).toBe("me@channel.com"); + }); +}); diff --git a/tests/utils/editor-issues.test.ts b/tests/utils/editor-issues.test.ts index 2b8ddb0..ce6fab1 100644 --- a/tests/utils/editor-issues.test.ts +++ b/tests/utils/editor-issues.test.ts @@ -87,6 +87,11 @@ describe("collectEditorIssues", () => { expect(issues.map((i) => i.id).sort()).toEqual(["adEmail", "gameKeyEmail"]); }); + it("ignores copyrightEmail while the split toggle is off", () => { + const editor = makeEditor({ copyrightEmail: "me@channel.com" }); + expect(collectEditorIssues(editor, { ...CTX, splitContactEmail: false })).toEqual([]); + }); + it("ignores the Zalo link outside Vietnamese output", () => { const editor = makeEditor({ zaloGroupLink: "https://wrong.example/x" }); expect(collectEditorIssues(editor, { ...CTX, language: "en" })).toEqual([]); @@ -98,12 +103,50 @@ describe("collectEditorIssues", () => { expect(issues[0]?.id).toBe("zaloGroupLink"); }); }); + + describe("purpose words (v1.1.0) — split mode only", () => { + const SPLIT: EditorIssueContext = { ...CTX, splitContactEmail: true }; + + it("errors on a purpose address without its word, naming the words", () => { + const editor = makeEditor({ + adEmail: "hello@channel.com", + gameKeyEmail: "me@channel.com", + copyrightEmail: "skullmute@gmail.com", + }); + const issues = collectEditorIssues(editor, SPLIT); + expect(issues.map((i) => i.id).sort()).toEqual(["adEmail", "copyrightEmail", "gameKeyEmail"]); + for (const issue of issues) { + expect(issue.severity).toBe("error"); + expect(issue.messageKey).toBe("validation.emailKeywordMissing"); + expect(issue.labelKey).toBe(`editor.${issue.id}`); + } + expect(issues.find((i) => i.id === "copyrightEmail")?.params).toMatchObject({ + email: "skullmute@gmail.com", + }); + }); + + it("accepts purpose addresses that carry their word", () => { + const editor = makeEditor({ + adEmail: "sponsors@channel.com", + gameKeyEmail: "keys@channel.com", + copyrightEmail: "channel+dmca@gmail.com", + }); + expect(collectEditorIssues(editor, SPLIT)).toEqual([]); + }); + + it("never asks the general contact address for a word", () => { + const editor = makeEditor({ contactEmail: "hello@channel.com" }); + expect(collectEditorIssues(editor, SPLIT)).toEqual([]); + }); + }); }); describe("isRelevantIssueId", () => { it("gates the split-email fields on the toggle", () => { expect(isRelevantIssueId("adEmail", { ...CTX, splitContactEmail: false })).toBe(false); expect(isRelevantIssueId("gameKeyEmail", { ...CTX, splitContactEmail: true })).toBe(true); + expect(isRelevantIssueId("copyrightEmail", { ...CTX, splitContactEmail: false })).toBe(false); + expect(isRelevantIssueId("copyrightEmail", { ...CTX, splitContactEmail: true })).toBe(true); }); it("gates the Zalo link on the output language", () => { diff --git a/tests/utils/validation.test.ts b/tests/utils/validation.test.ts index 33440c6..d60f26a 100644 --- a/tests/utils/validation.test.ts +++ b/tests/utils/validation.test.ts @@ -12,10 +12,15 @@ import { validateIntegerInRange, validateBatchRange, validateEmails, + validatePurposeEmails, countEmailSegments, canAcceptEmailInput, } from "@utils/validation"; import { PLATFORMS } from "@config/platforms"; +import { PURPOSE_EMAIL_KEYWORDS, type PurposeEmailField } from "@config/contact-emails"; +import { SUPPORTED_LANGUAGES } from "@i18n/index"; +import { readFileSync } from "fs"; +import { resolve } from "path"; function platform(id: string) { const p = PLATFORMS.find((x) => x.id === id); @@ -602,3 +607,81 @@ describe("v1.0.0 validation changes", () => { ); }); }); + +describe("validatePurposeEmails — v1.1.0 purpose words before @", () => { + it("accepts an address whose local part carries one of the field's words", () => { + expect(validatePurposeEmails("copyrightEmail", "dmca@skullmute.com").valid).toBe(true); + expect(validatePurposeEmails("copyrightEmail", "takedown@skullmute.com").valid).toBe(true); + expect(validatePurposeEmails("adEmail", "sponsorships@skullmute.com").valid).toBe(true); + expect(validatePurposeEmails("gameKeyEmail", "keys@skullmute.com").valid).toBe(true); + }); + + it("matches anywhere in the local part, ignoring case — plus-addressing included", () => { + expect(validatePurposeEmails("copyrightEmail", "SkullMute+DMCA@gmail.com").valid).toBe(true); + expect(validatePurposeEmails("adEmail", "skullmute.business@gmail.com").valid).toBe(true); + expect(validatePurposeEmails("gameKeyEmail", "Press-Team@studio.io").valid).toBe(true); + }); + + it("rejects an address without one, naming the address and the words", () => { + expect(validatePurposeEmails("copyrightEmail", "skullmute@gmail.com")).toEqual({ + valid: false, + error: "validation.emailKeywordMissing", + errorParams: { + email: "skullmute@gmail.com", + keywords: PURPOSE_EMAIL_KEYWORDS.copyrightEmail.join(", "), + }, + }); + }); + + it("only reads the part before @ — a word in the domain does not count", () => { + expect(validatePurposeEmails("copyrightEmail", "me@dmca-desk.com").valid).toBe(false); + }); + + it("checks every address and reports the first one without a word", () => { + const result = validatePurposeEmails("adEmail", "ads@a.com, hello@b.com, partner@c.com"); + expect(result.valid).toBe(false); + expect(result.errorParams?.email).toBe("hello@b.com"); + }); + + it("keeps each field to its own words", () => { + expect(validatePurposeEmails("adEmail", "dmca@skullmute.com").valid).toBe(false); + expect(validatePurposeEmails("copyrightEmail", "sponsors@skullmute.com").valid).toBe(false); + }); + + it("reports a malformed address or the cap before the purpose rule", () => { + expect(validatePurposeEmails("copyrightEmail", "dmca@").error).toBe("validation.emailInvalid"); + expect( + validatePurposeEmails("copyrightEmail", "dmca@a.com,dmca@b.com,dmca@c.com,dmca@d.com").error, + ).toBe("validation.emailMaxExceeded"); + }); + + it("treats an empty field as valid", () => { + expect(validatePurposeEmails("gameKeyEmail", "")).toEqual({ valid: true }); + expect(validatePurposeEmails("gameKeyEmail", " ")).toEqual({ valid: true }); + }); + + it("keeps every word lower-case and non-empty, since matching lower-cases the address", () => { + for (const words of Object.values(PURPOSE_EMAIL_KEYWORDS)) { + for (const word of words) { + expect(word).toBe(word.toLowerCase()); + expect(word.trim()).not.toBe(""); + } + } + }); + + it("is satisfied by every locale's own example address", () => { + const fields = Object.keys(PURPOSE_EMAIL_KEYWORDS) as PurposeEmailField[]; + for (const { id } of SUPPORTED_LANGUAGES) { + const ui = JSON.parse(readFileSync(resolve("src/i18n/locales", id, "ui.json"), "utf8")) as { + editor: Record; + }; + for (const field of fields) { + const example = ui.editor[`${field}Placeholder`] ?? ""; + expect(example, `${id} ${field}Placeholder`).not.toBe(""); + expect(validatePurposeEmails(field, example), `${id} ${field}: ${example}`).toEqual({ + valid: true, + }); + } + } + }); +});