brendmanager/src/channels.js

50 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Таблица каналов (BRM-56). Только то, что известно; остальное — «нужно уточнить» (null), без догадок.
// Тексты — в locales (ch.*), здесь только коды.
export const AUTO = ["no", "pending", "yes"]; // yes сейчас нет ни у одного канала
export const PRIORITIES = ["P0", "P1", "P2"];
const unknown = { audience: null, goal: null, role: null, metrics: null };
const base = (id, extra = {}) => ({
id, ...unknown, access: "unconfirmed", auto: "no", status: "unconfirmed", priority: null, link: null, ...extra,
});
export const CHANNELS = [
base("linkedin", { access: "profile", auto: "pending", status: "known", priority: "P0", link: null }),
base("instagram"), base("facebook"),
base("telegram", { auto: "pending", priority: "P0" }),
base("site", { access: "site", status: "known", priority: "P0", link: "https://growconsult.kz" }),
base("youtube"), base("tiktok"), base("threadsx"), base("email"),
base("media"), base("whatsapp"), base("search"),
];
export const channelView = (c) => ({ ...c, manualTask: c.auto !== "yes" });
export const listChannels = () => CHANNELS.map(channelView);
// BRM-146: матрица каналов — что можно сейчас, права, что мешает, запасной путь, следующий шаг.
// Только коды; тексты — ui.ch.m.*. Права подтверждены только у бота в закрытом тестовом канале (BRM-143).
export const PUBLIC_SEND = false; // публичная отправка выключена до отдельного решения владельца
export const TEST_CHANNEL_ID = "telegram-test"; // единственный канал публикатора, куда отправка разрешена
export const OFFICIAL = ["site", "telegram"]; // сайт и второй официальный канал (вопрос PM #1753)
export const PATH_STEPS = ["plan", "submit", "approve", "out"];
const m = (rights, blocks, can = ["approve", "pack"]) => ({ rights, blocks, can, fallback: "pack" });
export const MATRIX = {
linkedin: m("profile", ["appReview", "publicOff"], ["approve", "pack", "trial"]),
instagram: m("unconfirmed", ["noAccess", "publicOff"]),
facebook: m("unconfirmed", ["noAccess", "publicOff"]),
telegram: m("botTest", ["noBotRights", "publicOff"], ["approve", "pack", "testSend"]),
site: m("site", ["noSiteAccess", "publicOff"]),
youtube: m("unconfirmed", ["noAccess", "video", "publicOff"]),
tiktok: m("unconfirmed", ["noAccess", "video", "publicOff"]),
threadsx: m("unconfirmed", ["noAccess", "publicOff"]),
email: m("unconfirmed", ["noList", "publicOff"]),
media: m("unconfirmed", ["organizers"], ["approve", "pack", "letters"]),
whatsapp: m("unconfirmed", ["noNumber", "publicOff"]),
search: m("unconfirmed", ["notPublication"], ["pack"]),
};
// права подтверждены — только то, что проверено (сейчас ни один официальный канал)
export const rightsConfirmed = (id) => MATRIX[id]?.rights === "confirmed";
export const matrixRows = () => CHANNELS.map((c) => ({ id: c.id, ...MATRIX[c.id], next: c.id, official: OFFICIAL.includes(c.id) }));
// для publisher.gate: причина отказа или null
export const publicGate = ({ channel }) => (!PUBLIC_SEND && channel !== TEST_CHANNEL_ID ? "public-off" : null);