This commit is contained in:
payacom
2026-07-23 15:58:15 +03:30
parent af5b27b610
commit a1d7db5e7e
445 changed files with 23456 additions and 8865 deletions

41
src/lib/captionLength.ts Normal file
View File

@@ -0,0 +1,41 @@
import {
buildPostLinkCaptionHeader,
SelectedPostLink,
} from "@/lib/postLinkCaption";
import type { AppLanguage } from "@/lib/i18n/registry";
export const POST_CAPTION_MAX_LENGTH = 2000;
export function buildFullPostCaption(
description: string,
taggedUsers: Array<{ user_name: string }>,
packages: SelectedPostLink[],
projects: SelectedPostLink[],
billboards: SelectedPostLink[],
lang?: AppLanguage
): string {
const tagLine = taggedUsers.map((u) => `@${u.user_name}`).join(" ");
const linkHeader = buildPostLinkCaptionHeader(
[...packages, ...projects, ...billboards],
lang
);
return [description.trim(), tagLine, linkHeader].filter(Boolean).join("\n");
}
export function countPostCaptionLength(
description: string,
taggedUsers: Array<{ user_name: string }>,
packages: SelectedPostLink[],
projects: SelectedPostLink[],
billboards: SelectedPostLink[],
lang?: AppLanguage
): number {
return buildFullPostCaption(
description,
taggedUsers,
packages,
projects,
billboards,
lang
).length;
}