feat: add Messenger community + VN Zalo group links (v0.32.0)

Add two "join the chat" community links that render into a single
"💬 COMMUNITY" description block:

- Messenger community (https://m.me/[id]) — shown for every language.
- Zalo group (https://zalo.me/g/<code>) — Zalo is a Vietnam-audience
  app, so the editor input only appears (and the description line only
  renders) when the output language is Vietnamese, mirroring the VN
  donate block. A value entered while in Vietnamese is preserved if the
  creator switches language.

Both links are hard-validated (validateMessengerUrl / validateZaloGroupUrl)
so a malformed URL never reaches the output. New editor-store fields
persist via a v15→v16 migration and round-trip through saved templates.

i18n across all 6 locales (967 ui / 559 templates). Tests 560→581.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 4.8 committed 2026-07-08 20:47:53 +07:00
1 parent e5776fa38c
commit 12b0099238
31 files changed
+428 -14

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "yt-desc-gen",
"version": "0.31.0",
"version": "0.32.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "yt-desc-gen",
"version": "0.31.0",
"version": "0.32.0",
"license": "Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.11.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "yt-desc-gen",
"version": "0.31.0",
"version": "0.32.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
+1 -1
View File
@@ -5535,7 +5535,7 @@ dependencies = [
[[package]]
name = "yt-desc-gen"
version = "0.31.0"
version = "0.32.0"
dependencies = [
"tauri",
"tauri-build",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "yt-desc-gen"
version = "0.31.0"
version = "0.32.0"
description = "YouTube Gameplay Description Generator"
authors = ["poli0981"]
edition = "2021"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
"productName": "YTDescGen",
"version": "0.31.0",
"version": "0.32.0",
"identifier": "com.skullmute.ytdescgen",
"build": {
"beforeBuildCommand": "npm run build",
+61
View File
@@ -0,0 +1,61 @@
import { useTranslation } from "react-i18next";
import { ValidatedInput } from "@components/ui/ValidatedInput";
import { useEditorStore } from "@store/editor-store";
import { validateMessengerUrl, validateZaloGroupUrl } from "@utils/validation";
/**
* Community invite links (v0.32.0). A single section for "join the chat"
* links that feed the description's "💬 COMMUNITY" block:
*
* - Messenger community (`https://m.me/<id>`) — shown for every output
* language.
* - Zalo group (`https://zalo.me/g/<code>`) — Zalo is a Vietnam-audience
* app, so the input only appears (and the description line only renders)
* when the output language is Vietnamese. A value entered while in
* Vietnamese is preserved if the creator later switches language.
*
* Both inputs hard-reject malformed links via {@link ValidatedInput}, so a
* bad URL never reaches the generated description.
*/
export function CommunityEditor() {
const { t } = useTranslation("ui");
const messengerCommunityLink = useEditorStore((s) => s.messengerCommunityLink);
const zaloGroupLink = useEditorStore((s) => s.zaloGroupLink);
const language = useEditorStore((s) => s.language);
const setField = useEditorStore((s) => s.set);
const isVi = language === "vi";
return (
<div className="flex flex-col gap-3">
<div className="flex flex-col gap-1">
<span className="text-sm font-medium text-text-secondary">
{t("editor.community")}
</span>
<p className="text-xs text-text-muted">{t("editor.communityHelp")}</p>
</div>
<ValidatedInput
label={t("editor.messengerCommunityLink")}
placeholder={t("editor.messengerCommunityLinkPlaceholder")}
value={messengerCommunityLink}
onChange={(v) => setField("messengerCommunityLink", v)}
validate={validateMessengerUrl}
inputMode="url"
autoComplete="off"
/>
{isVi && (
<ValidatedInput
label={t("editor.zaloGroupLink")}
placeholder={t("editor.zaloGroupLinkPlaceholder")}
value={zaloGroupLink}
onChange={(v) => setField("zaloGroupLink", v)}
validate={validateZaloGroupUrl}
inputMode="url"
autoComplete="off"
/>
)}
</div>
);
}
@@ -80,6 +80,8 @@ export function TemplateSaveForm({ open, onClose }: TemplateSaveFormProps) {
vnBankHolder: editor.vnBankHolder,
vnMomo: editor.vnMomo,
vnZalopay: editor.vnZalopay,
messengerCommunityLink: editor.messengerCommunityLink,
zaloGroupLink: editor.zaloGroupLink,
};
addTemplate(name, snapshot);
toast.success(t("templates.savedAs", { name: name.trim() || "Untitled" }));
+6
View File
@@ -138,6 +138,10 @@ export interface EditorDefaults {
playtestPlatform: string;
/** Playtest invites available, 0..platform max (≤100). 0 = unset. */
playtestInvites: number;
/** Messenger community invite link (v0.32.0). `https://m.me/<id>`. Empty = no community line. */
messengerCommunityLink: string;
/** Zalo group invite link (v0.32.0). `https://zalo.me/g/<code>`. Rendered only for Vietnamese output. */
zaloGroupLink: string;
}
export interface SettingsDefaults {
@@ -218,6 +222,8 @@ export const DEFAULTS = {
playtestLink: "",
playtestPlatform: DEFAULT_PLAYTEST_PLATFORM,
playtestInvites: 0,
messengerCommunityLink: "",
zaloGroupLink: "",
} satisfies EditorDefaults,
settings: {
+16
View File
@@ -667,6 +667,22 @@ export function buildDescription(
sections.push(`${t("description.sections.social")}\n${socialEntries.join("\n")}`);
}
// 10.5 Community — a single "💬 COMMUNITY" block for "join the chat"
// invites. Messenger renders for every language; the Zalo group is a
// Vietnam-audience app so its line is gated on Vietnamese output (same
// rationale as the VN donate block above). The whole block is skipped
// when neither eligible link is present.
const communityLines: string[] = [];
const messenger = input.messengerCommunityLink?.trim() ?? "";
if (messenger) communityLines.push(`💬 Messenger: ${messenger}`);
const zalo = input.zaloGroupLink?.trim() ?? "";
if (zalo && input.language === "vi") communityLines.push(`💙 Zalo: ${zalo}`);
if (communityLines.length > 0) {
sections.push(
`${t("description.sections.community")}\n${communityLines.join("\n")}`,
);
}
// 11. Playlist
if (input.playlistLink && input.playlistLink.trim()) {
sections.push(t("description.sections.playlist", { link: input.playlistLink }));
+9
View File
@@ -833,6 +833,15 @@ export interface GeneratorInput {
playtestLink?: string;
playtestPlatform?: string;
playtestInvites?: number;
/**
* Community invite links (v0.32.0). {@link messengerCommunityLink}
* (`https://m.me/<id>`) renders for every language; {@link zaloGroupLink}
* (`https://zalo.me/g/<code>`) is gated on {@link language} === `"vi"`
* (Zalo is a Vietnam-audience app). Both feed a single "💬 COMMUNITY"
* block, which is omitted when it would be empty.
*/
messengerCommunityLink?: string;
zaloGroupLink?: string;
}
export interface GeneratorOutput {
+2
View File
@@ -97,6 +97,8 @@ export function buildGeneratorInputFromEditor(
playtestLink: state.playtestLink,
playtestPlatform: state.playtestPlatform,
playtestInvites: state.playtestInvites,
messengerCommunityLink: state.messengerCommunityLink,
zaloGroupLink: state.zaloGroupLink,
};
}
+5 -1
View File
@@ -47,6 +47,9 @@
"timestamps", "timestampsPlaceholder",
"storeLinks", "storeLinkType", "rig", "social", "warnings",
"playlistLink", "playlistLinkPlaceholder",
"community", "communityHelp",
"messengerCommunityLink", "messengerCommunityLinkPlaceholder",
"zaloGroupLink", "zaloGroupLinkPlaceholder",
"contactEmail", "contactEmailPlaceholder", "contactEmailHelp",
"musicAttribution", "musicAttributionPlaceholder",
"sponsorName", "sponsorNamePlaceholder",
@@ -187,7 +190,7 @@
"socialPost": ["title", "single", "bulk", "copyCaption", "emptyState", "trimmedHint", "overLimitHint", "exported", "exportFailed", "imported", "importFailed", "importedHeading"],
"socialPost.platforms": ["tiktok", "instagram_reels", "facebook_reels"],
"shortcuts": ["title", "generate", "copyAll", "saveDraft", "toggleSidebar", "help", "close", "searchPlaceholder", "noResults"],
"validation": ["emailInvalid", "emailMaxExceeded", "urlInvalid", "urlPrefixMismatch", "playlistUrlInvalid", "numberRequired", "numberInvalid", "numberNotInteger", "numberOutOfRange", "rangeEndBeforeStart", "rangeTooLarge"],
"validation": ["emailInvalid", "emailMaxExceeded", "urlInvalid", "urlPrefixMismatch", "playlistUrlInvalid", "messengerUrlInvalid", "zaloUrlInvalid", "numberRequired", "numberInvalid", "numberNotInteger", "numberOutOfRange", "rangeEndBeforeStart", "rangeTooLarge"],
"logs": ["title", "emptyState", "clearAll", "clearConfirm", "clearPersistedConfirm", "clearSession", "searchPlaceholder", "exportJson", "exportTxt", "sessionCurrent", "sessionLabel", "entriesShort"],
"playlist": ["title", "status", "contentType", "totalVideos", "customNote", "generatePlaylist", "droppedReasonsLabel", "droppedReasonCustomLabel", "droppedReasonCustomPlaceholder", "pinnedComment"],
"playlist.droppedReasons": ["boring", "performance", "bugs", "delisted", "low_views", "time"]
@@ -219,6 +222,7 @@
"timestamps", "storeLinksBuy", "storeLinksDownload", "gameCopyright", "playtest", "playtestInvites", "videoSettings", "rig",
"modList", "vnDonate",
"sponsorCredit", "thirdPartyAds", "music", "donate", "social",
"community",
"playlist", "contact", "cta",
"copyright", "usagePolicyHeader", "usagePolicy"
],
+1
View File
@@ -120,6 +120,7 @@
"music": "🎵 MUSIC / SOUND",
"donate": "☕ SUPPORT THE CHANNEL",
"social": "🔗 FOLLOW ME",
"community": "💬 COMMUNITY / JOIN THE GROUP",
"playlist": "▶️ Watch the full series: {{link}}",
"contact": "📧 Business inquiries: {{email}}",
"cta": "👍 Like | 🔔 Subscribe | ↗️ Share",
+9 -1
View File
@@ -292,6 +292,12 @@
"warnings": "Content warnings",
"playlistLink": "Playlist Link",
"playlistLinkPlaceholder": "https://youtube.com/playlist?list=...",
"community": "💬 Community",
"communityHelp": "Links to your community chat. The Zalo group only shows when the content language is Vietnamese.",
"messengerCommunityLink": "Messenger Community Link",
"messengerCommunityLinkPlaceholder": "https://m.me/yourpage",
"zaloGroupLink": "Zalo Group Link",
"zaloGroupLinkPlaceholder": "https://zalo.me/g/xxxxxx",
"contactEmail": "Contact Email",
"contactEmailPlaceholder": "business@example.com",
"musicAttribution": "Music / Sound Attribution",
@@ -1065,7 +1071,9 @@
"emailMaxExceeded": "Maximum {{max}} emails allowed (currently {{count}})",
"urlInvalid": "Invalid URL. Must start with https://",
"urlPrefixMismatch": "Expected URL starting with {{expected}}",
"playlistUrlInvalid": "Invalid YouTube playlist URL. Expected: {{expected}}"
"playlistUrlInvalid": "Invalid YouTube playlist URL. Expected: {{expected}}",
"messengerUrlInvalid": "Invalid Messenger link. Expected: {{expected}}",
"zaloUrlInvalid": "Invalid Zalo group link. Expected: {{expected}}"
},
"storeLinkTypes": {
"paid": "Paid",
+1
View File
@@ -120,6 +120,7 @@
"music": "🎵 MÚSICA / SONIDO",
"donate": "☕ APOYA EL CANAL",
"social": "🔗 SÍGUEME",
"community": "💬 COMUNIDAD / ÚNETE AL GRUPO",
"playlist": "▶️ Ver la serie completa: {{link}}",
"contact": "📧 Consultas comerciales: {{email}}",
"cta": "👍 Me gusta | 🔔 Suscríbete | ↗️ Comparte",
+9 -1
View File
@@ -292,6 +292,12 @@
"warnings": "Advertencias de contenido",
"playlistLink": "Enlace de Lista de Reproducción",
"playlistLinkPlaceholder": "https://youtube.com/playlist?list=...",
"community": "💬 Comunidad",
"communityHelp": "Enlaces al chat de tu comunidad. El grupo de Zalo solo aparece cuando el idioma del contenido es vietnamita.",
"messengerCommunityLink": "Enlace de comunidad de Messenger",
"messengerCommunityLinkPlaceholder": "https://m.me/yourpage",
"zaloGroupLink": "Enlace de grupo de Zalo",
"zaloGroupLinkPlaceholder": "https://zalo.me/g/xxxxxx",
"contactEmail": "Correo de Contacto",
"contactEmailPlaceholder": "negocios@ejemplo.com",
"musicAttribution": "Crédito Musical / Sonidos",
@@ -1065,7 +1071,9 @@
"emailMaxExceeded": "Máximo {{max}} emails permitidos (actualmente {{count}})",
"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}}"
"playlistUrlInvalid": "URL de lista de reproducción de YouTube inválida. Se espera: {{expected}}",
"messengerUrlInvalid": "Enlace de Messenger inválido. Se espera: {{expected}}",
"zaloUrlInvalid": "Enlace de grupo de Zalo inválido. Se espera: {{expected}}"
},
"storeLinkTypes": {
"paid": "De pago",
+1
View File
@@ -120,6 +120,7 @@
"music": "🎵 音楽・サウンド",
"donate": "☕ チャンネルを応援",
"social": "🔗 フォローする",
"community": "💬 コミュニティ / グループに参加",
"playlist": "▶️ シリーズ全体を見る:{{link}}",
"contact": "📧 お仕事の依頼:{{email}}",
"cta": "👍 いいね | 🔔 チャンネル登録 | ↗️ シェア",
+9 -1
View File
@@ -292,6 +292,12 @@
"warnings": "コンテンツ警告",
"playlistLink": "プレイリストリンク",
"playlistLinkPlaceholder": "https://youtube.com/playlist?list=...",
"community": "💬 コミュニティ",
"communityHelp": "コミュニティチャットへのリンク。Zaloグループはコンテンツ言語がベトナム語の場合のみ表示されます。",
"messengerCommunityLink": "Messengerコミュニティリンク",
"messengerCommunityLinkPlaceholder": "https://m.me/yourpage",
"zaloGroupLink": "Zaloグループリンク",
"zaloGroupLinkPlaceholder": "https://zalo.me/g/xxxxxx",
"contactEmail": "連絡先メール",
"contactEmailPlaceholder": "business@example.com",
"musicAttribution": "音楽・サウンドクレジット",
@@ -1065,7 +1071,9 @@
"emailMaxExceeded": "最大{{max}}件のメール (現在{{count}}件)",
"urlInvalid": "無効なURL。https://で始める必要があります",
"urlPrefixMismatch": "{{expected}}で始まるURLが必要です",
"playlistUrlInvalid": "無効なYouTubeプレイリストURLです。期待される形式: {{expected}}"
"playlistUrlInvalid": "無効なYouTubeプレイリストURLです。期待される形式: {{expected}}",
"messengerUrlInvalid": "無効なMessengerリンクです。期待される形式: {{expected}}",
"zaloUrlInvalid": "無効なZaloグループリンクです。期待される形式: {{expected}}"
},
"storeLinkTypes": {
"paid": "有料",
+1
View File
@@ -120,6 +120,7 @@
"music": "🎵 음악 / 사운드",
"donate": "☕ 채널 후원",
"social": "🔗 팔로우",
"community": "💬 커뮤니티 / 그룹 참여",
"playlist": "▶️ 전체 시리즈 보기: {{link}}",
"contact": "📧 비즈니스 문의: {{email}}",
"cta": "👍 좋아요 | 🔔 구독 | ↗️ 공유",
+9 -1
View File
@@ -292,6 +292,12 @@
"warnings": "콘텐츠 경고",
"playlistLink": "재생목록 링크",
"playlistLinkPlaceholder": "https://youtube.com/playlist?list=...",
"community": "💬 커뮤니티",
"communityHelp": "커뮤니티 채팅 링크입니다. Zalo 그룹은 콘텐츠 언어가 베트남어일 때만 표시됩니다.",
"messengerCommunityLink": "Messenger 커뮤니티 링크",
"messengerCommunityLinkPlaceholder": "https://m.me/yourpage",
"zaloGroupLink": "Zalo 그룹 링크",
"zaloGroupLinkPlaceholder": "https://zalo.me/g/xxxxxx",
"contactEmail": "문의 이메일",
"contactEmailPlaceholder": "business@example.com",
"musicAttribution": "음악 / 사운드 크레딧",
@@ -1065,7 +1071,9 @@
"emailMaxExceeded": "최대 {{max}}개 이메일 허용 (현재 {{count}}개)",
"urlInvalid": "잘못된 URL입니다. https://로 시작해야 합니다",
"urlPrefixMismatch": "{{expected}}로 시작하는 URL이 필요합니다",
"playlistUrlInvalid": "잘못된 YouTube 재생목록 URL입니다. 예상 형식: {{expected}}"
"playlistUrlInvalid": "잘못된 YouTube 재생목록 URL입니다. 예상 형식: {{expected}}",
"messengerUrlInvalid": "잘못된 Messenger 링크입니다. 예상 형식: {{expected}}",
"zaloUrlInvalid": "잘못된 Zalo 그룹 링크입니다. 예상 형식: {{expected}}"
},
"storeLinkTypes": {
"paid": "유료",
+1
View File
@@ -120,6 +120,7 @@
"music": "🎵 NHẠC / ÂM THANH",
"donate": "☕ ỦNG HỘ KÊNH",
"social": "🔗 THEO DÕI MÌNH",
"community": "💬 CỘNG ĐỒNG / THAM GIA NHÓM",
"playlist": "▶️ Xem toàn bộ series: {{link}}",
"contact": "📧 Liên hệ hợp tác: {{email}}",
"cta": "👍 Like | 🔔 Đăng ký | ↗️ Chia sẻ",
+9 -1
View File
@@ -292,6 +292,12 @@
"warnings": "Cảnh báo nội dung",
"playlistLink": "Link Playlist",
"playlistLinkPlaceholder": "https://youtube.com/playlist?list=...",
"community": "💬 Cộng đồng",
"communityHelp": "Link nhóm chat cộng đồng. Nhóm Zalo chỉ hiển thị khi ngôn ngữ nội dung là Tiếng Việt.",
"messengerCommunityLink": "Link cộng đồng Messenger",
"messengerCommunityLinkPlaceholder": "https://m.me/yourpage",
"zaloGroupLink": "Link nhóm Zalo",
"zaloGroupLinkPlaceholder": "https://zalo.me/g/xxxxxx",
"contactEmail": "Email liên hệ",
"contactEmailPlaceholder": "business@example.com",
"musicAttribution": "Credit nhạc / âm thanh",
@@ -1065,7 +1071,9 @@
"emailMaxExceeded": "Tối đa {{max}} email (hiện tại {{count}})",
"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}}"
"playlistUrlInvalid": "URL playlist YouTube không hợp lệ. Định dạng mong muốn: {{expected}}",
"messengerUrlInvalid": "Link Messenger không hợp lệ. Định dạng mong muốn: {{expected}}",
"zaloUrlInvalid": "Link nhóm Zalo không hợp lệ. Định dạng mong muốn: {{expected}}"
},
"storeLinkTypes": {
"paid": "Trả phí",
+1
View File
@@ -120,6 +120,7 @@
"music": "🎵 音乐 / 音效",
"donate": "☕ 支持频道",
"social": "🔗 关注我",
"community": "💬 社区 / 加入群组",
"playlist": "▶️ 观看完整系列:{{link}}",
"contact": "📧 商务合作:{{email}}",
"cta": "👍 点赞 | 🔔 订阅 | ↗️ 分享",
+9 -1
View File
@@ -292,6 +292,12 @@
"warnings": "内容警告",
"playlistLink": "播放列表链接",
"playlistLinkPlaceholder": "https://youtube.com/playlist?list=...",
"community": "💬 社区",
"communityHelp": "社区聊天链接。Zalo 群仅在内容语言为越南语时显示。",
"messengerCommunityLink": "Messenger 社区链接",
"messengerCommunityLinkPlaceholder": "https://m.me/yourpage",
"zaloGroupLink": "Zalo 群链接",
"zaloGroupLinkPlaceholder": "https://zalo.me/g/xxxxxx",
"contactEmail": "联系邮箱",
"contactEmailPlaceholder": "business@example.com",
"musicAttribution": "音乐 / 音效署名",
@@ -1065,7 +1071,9 @@
"emailMaxExceeded": "最多允许{{max}}个邮箱 (当前{{count}}个)",
"urlInvalid": "无效URL。必须以https://开头",
"urlPrefixMismatch": "URL应以{{expected}}开头",
"playlistUrlInvalid": "无效的YouTube播放列表URL。期望格式: {{expected}}"
"playlistUrlInvalid": "无效的YouTube播放列表URL。期望格式: {{expected}}",
"messengerUrlInvalid": "无效的Messenger链接。期望格式: {{expected}}",
"zaloUrlInvalid": "无效的Zalo群链接。期望格式: {{expected}}"
},
"storeLinkTypes": {
"paid": "付费",
+2
View File
@@ -10,6 +10,7 @@ import { PlaytestEditor } from "@components/editor/PlaytestEditor";
import { RigEditor } from "@components/editor/RigEditor";
import { SocialEditor } from "@components/editor/SocialEditor";
import { VietnameseDonateEditor } from "@components/editor/VietnameseDonateEditor";
import { CommunityEditor } from "@components/editor/CommunityEditor";
import { ContentWarningChecklist } from "@components/editor/ContentWarningChecklist";
import { PlaythroughNotesForm } from "@components/editor/PlaythroughNotesForm";
import { TechNotesChecklist } from "@components/editor/TechNotesChecklist";
@@ -155,6 +156,7 @@ export function EditorPage() {
<StoreLinkEditor />
<PlaytestEditor />
<SocialEditor />
<CommunityEditor />
<VietnameseDonateEditor />
</Accordion>
</div>
+22 -1
View File
@@ -179,6 +179,10 @@ export interface EditorData {
playtestPlatform: string;
/** Playtest invites available — 0 = unset; clamped to the platform max (≤100). */
playtestInvites: number;
/** Messenger community invite link (v0.32.0). Empty = no community line. */
messengerCommunityLink: string;
/** Zalo group invite link (v0.32.0). Rendered into the description only for Vietnamese output. */
zaloGroupLink: string;
}
/**
@@ -362,6 +366,8 @@ const initialState: EditorData = {
playtestLink: DEFAULTS.editor.playtestLink,
playtestPlatform: DEFAULTS.editor.playtestPlatform,
playtestInvites: DEFAULTS.editor.playtestInvites,
messengerCommunityLink: DEFAULTS.editor.messengerCommunityLink,
zaloGroupLink: DEFAULTS.editor.zaloGroupLink,
};
export const useEditorStore = create<EditorState>()(
@@ -486,7 +492,13 @@ export const useEditorStore = create<EditorState>()(
// the default and clamps the invite count to an integer in
// [0, 100], so a hand-edited blob can't strand the editor's
// platform Select or number input on a bad value.
version: 15,
// v15 → v16: v0.32.0. Community links — `messengerCommunityLink`
// (`https://m.me/<id>`) and `zaloGroupLink`
// (`https://zalo.me/g/<code>`) joined the schema. Additive:
// both back-fill to "". Messenger renders for every output
// language; the Zalo line only renders for Vietnamese output.
// Non-string values coerce to "".
version: 16,
migrate: (persistedState, version) =>
migrateEditorState(persistedState, version),
partialize: (state) => ({
@@ -561,6 +573,8 @@ export const useEditorStore = create<EditorState>()(
playtestLink: state.playtestLink,
playtestPlatform: state.playtestPlatform,
playtestInvites: state.playtestInvites,
messengerCommunityLink: state.messengerCommunityLink,
zaloGroupLink: state.zaloGroupLink,
}),
},
),
@@ -798,6 +812,13 @@ export function migrateEditorState(
? Math.min(inv, PLAYTEST_MAX_INVITES_CAP)
: 0;
}
if (version < 16) {
// v0.32.0 Community links. Additive back-fill + defensive coercion.
if (typeof state.messengerCommunityLink !== "string") {
state.messengerCommunityLink = "";
}
if (typeof state.zaloGroupLink !== "string") state.zaloGroupLink = "";
}
return { ...initialState, ...state } as EditorData;
}
+3
View File
@@ -120,6 +120,9 @@ export interface TemplateSnapshot {
vnBankHolder?: string;
vnMomo?: string;
vnZalopay?: string;
/** Community invite links (v0.32.0). Optional for back-compat. */
messengerCommunityLink?: string;
zaloGroupLink?: string;
/** Channel-level third-party advertising copy (v0.11). Optional for
* back-compat with pre-v0.11 templates. */
thirdPartyAdText?: string;
+51
View File
@@ -137,6 +137,57 @@ export function validatePlaylistUrl(input: string): ValidationResult {
return { valid: true };
}
/**
* Strict validators for community-invite links (v0.32.0).
*
* - Messenger community: `https://m.me/<id>` — the id is a page username or
* numeric page id. Non-`m.me` URLs are hard-rejected so a broken invite
* never reaches the description.
* - Zalo group: `https://zalo.me/g/<code>` — the `/g/` path is the group
* join link, distinct from a personal `zalo.me/<phone>` profile. Only
* rendered for Vietnamese output, but validated regardless of language.
*/
const MESSENGER_URL_REGEX = /^https:\/\/m\.me\/[A-Za-z0-9._-]+$/;
const MESSENGER_URL_EXPECTED = "https://m.me/[id]";
const ZALO_GROUP_URL_REGEX = /^https:\/\/zalo\.me\/g\/[A-Za-z0-9]+$/;
const ZALO_GROUP_URL_EXPECTED = "https://zalo.me/g/[id]";
export function validateMessengerUrl(input: string): ValidationResult {
const trimmed = input.trim();
if (!trimmed) return { valid: true };
const baseResult = validateUrl(trimmed);
if (!baseResult.valid) return baseResult;
if (!MESSENGER_URL_REGEX.test(trimmed)) {
return {
valid: false,
error: "validation.messengerUrlInvalid",
errorParams: { expected: MESSENGER_URL_EXPECTED },
};
}
return { valid: true };
}
export function validateZaloGroupUrl(input: string): ValidationResult {
const trimmed = input.trim();
if (!trimmed) return { valid: true };
const baseResult = validateUrl(trimmed);
if (!baseResult.valid) return baseResult;
if (!ZALO_GROUP_URL_REGEX.test(trimmed)) {
return {
valid: false,
error: "validation.zaloUrlInvalid",
errorParams: { expected: ZALO_GROUP_URL_EXPECTED },
};
}
return { valid: true };
}
export interface IntRangeOptions {
min: number;
max: number;
+69
View File
@@ -533,6 +533,75 @@ describe("buildDescription", () => {
expect(result).not.toContain("💸 MoMo");
});
it("renders the community block with the Messenger line for any language (v0.32.0)", () => {
const t = createMockT("en");
const result = buildDescription(
makeInput({ messengerCommunityLink: "https://m.me/mychannel" }),
t,
);
expect(result).toContain("💬 COMMUNITY / JOIN THE GROUP");
expect(result).toContain("💬 Messenger: https://m.me/mychannel");
expect(result).not.toContain("💙 Zalo");
});
it("renders the Zalo group line when language is 'vi' (v0.32.0)", () => {
const t = createMockT("en");
const result = buildDescription(
makeInput({
language: "vi",
messengerCommunityLink: "https://m.me/mychannel",
zaloGroupLink: "https://zalo.me/g/abc123",
}),
t,
);
expect(result).toContain("💬 Messenger: https://m.me/mychannel");
expect(result).toContain("💙 Zalo: https://zalo.me/g/abc123");
});
it("never renders the Zalo group line when language is not 'vi', even if set (v0.32.0)", () => {
const t = createMockT("en");
const result = buildDescription(
makeInput({
language: "en",
messengerCommunityLink: "https://m.me/mychannel",
zaloGroupLink: "https://zalo.me/g/abc123",
}),
t,
);
// Messenger is language-agnostic and still renders…
expect(result).toContain("💬 Messenger: https://m.me/mychannel");
// …but the Zalo line is gated to Vietnamese output.
expect(result).not.toContain("💙 Zalo");
expect(result).not.toContain("zalo.me/g/abc123");
});
it("omits the community block entirely when it would be empty (v0.32.0)", () => {
const t = createMockT("en");
// Zalo is set but the output language is English and there's no
// Messenger link → the block has no eligible lines and is skipped.
const result = buildDescription(
makeInput({ language: "en", zaloGroupLink: "https://zalo.me/g/abc123" }),
t,
);
expect(result).not.toContain("COMMUNITY / JOIN THE GROUP");
expect(result).not.toContain("💬 Messenger");
expect(result).not.toContain("💙 Zalo");
});
it("localizes the community heading for Vietnamese output (v0.32.0)", () => {
const t = createMockT("vi");
const result = buildDescription(
makeInput({
language: "vi",
messengerCommunityLink: "https://m.me/mychannel",
zaloGroupLink: "https://zalo.me/g/abc123",
}),
t,
);
expect(result).toContain("CỘNG ĐỒNG / THAM GIA NHÓM");
expect(result).toContain("💙 Zalo: https://zalo.me/g/abc123");
});
it("renders the Mod List block when videoType is 'mods' and modList is non-empty", () => {
const t = createMockT("en");
const modList = "• Requiem\n• NaturalVision Evolved\n• Custom Skinpack v2.1";
+43
View File
@@ -262,3 +262,46 @@ describe("migrateEditorState — v14 → v15 (v0.30.0 Playtest)", () => {
expect(result.playtestInvites).toBe(40);
});
});
describe("migrateEditorState — v15 → v16 (v0.32.0 Community links)", () => {
// Build a pre-v16 blob by routing v9 through every prior migration, then
// strip the community keys so the v16 block is what supplies them.
function makeV15Persisted(
overrides: Record<string, unknown> = {},
): Record<string, unknown> {
const full = migrateEditorState(makeV9Persisted(), 9) as unknown as Record<
string,
unknown
>;
delete full.messengerCommunityLink;
delete full.zaloGroupLink;
return { ...full, ...overrides };
}
it("back-fills the community link fields with empty strings", () => {
const result = migrateEditorState(makeV15Persisted(), 15);
expect(result.messengerCommunityLink).toBe("");
expect(result.zaloGroupLink).toBe("");
});
it("coerces non-string persisted community values to empty strings", () => {
const result = migrateEditorState(
makeV15Persisted({ messengerCommunityLink: 42, zaloGroupLink: null }),
15,
);
expect(result.messengerCommunityLink).toBe("");
expect(result.zaloGroupLink).toBe("");
});
it("preserves valid persisted community links", () => {
const result = migrateEditorState(
makeV15Persisted({
messengerCommunityLink: "https://m.me/mychannel",
zaloGroupLink: "https://zalo.me/g/abc123",
}),
15,
);
expect(result.messengerCommunityLink).toBe("https://m.me/mychannel");
expect(result.zaloGroupLink).toBe("https://zalo.me/g/abc123");
});
});
+71
View File
@@ -2,6 +2,8 @@ import { describe, it, expect } from "vitest";
import {
validateUrlWithPattern,
validatePlaylistUrl,
validateMessengerUrl,
validateZaloGroupUrl,
validateIntegerInRange,
validateBatchRange,
} from "@utils/validation";
@@ -244,6 +246,75 @@ describe("validatePlaylistUrl", () => {
});
});
describe("validateMessengerUrl", () => {
it("accepts a canonical m.me link with a username", () => {
const result = validateMessengerUrl("https://m.me/mychannel");
expect(result.valid).toBe(true);
expect(result.error).toBeUndefined();
});
it("accepts a numeric page id", () => {
expect(validateMessengerUrl("https://m.me/100123456789").valid).toBe(true);
});
it("accepts ids with dots, dashes and underscores", () => {
expect(validateMessengerUrl("https://m.me/my.page_name-1").valid).toBe(true);
});
it("rejects a non-m.me host", () => {
const result = validateMessengerUrl("https://messenger.com/mychannel");
expect(result.valid).toBe(false);
expect(result.error).toBe("validation.messengerUrlInvalid");
expect(result.errorParams?.expected).toBe("https://m.me/[id]");
});
it("rejects the bare m.me host with no id", () => {
expect(validateMessengerUrl("https://m.me/").valid).toBe(false);
expect(validateMessengerUrl("https://m.me").valid).toBe(false);
});
it("rejects an http (non-https) link", () => {
expect(validateMessengerUrl("http://m.me/mychannel").valid).toBe(false);
});
it("accepts empty input (not an error)", () => {
expect(validateMessengerUrl("").valid).toBe(true);
expect(validateMessengerUrl(" ").valid).toBe(true);
});
});
describe("validateZaloGroupUrl", () => {
it("accepts a canonical zalo.me group link", () => {
const result = validateZaloGroupUrl("https://zalo.me/g/abc123");
expect(result.valid).toBe(true);
expect(result.error).toBeUndefined();
});
it("rejects a personal zalo.me profile (no /g/ path)", () => {
const result = validateZaloGroupUrl("https://zalo.me/0901234567");
expect(result.valid).toBe(false);
expect(result.error).toBe("validation.zaloUrlInvalid");
expect(result.errorParams?.expected).toBe("https://zalo.me/g/[id]");
});
it("rejects the bare group path with no code", () => {
expect(validateZaloGroupUrl("https://zalo.me/g/").valid).toBe(false);
});
it("rejects a non-zalo.me host", () => {
expect(validateZaloGroupUrl("https://example.com/g/abc123").valid).toBe(false);
});
it("rejects an http (non-https) link", () => {
expect(validateZaloGroupUrl("http://zalo.me/g/abc123").valid).toBe(false);
});
it("accepts empty input (not an error)", () => {
expect(validateZaloGroupUrl("").valid).toBe(true);
expect(validateZaloGroupUrl(" ").valid).toBe(true);
});
});
describe("validateIntegerInRange", () => {
it("accepts a whole number within range", () => {
expect(validateIntegerInRange("5", { min: 1, max: 10 }).valid).toBe(true);