Merge pull request 'BRM-119: убрать «Рассылка уже идёт», пока Telegram не подключён' (#114) from task/brm-119 into main

This commit is contained in:
peppa-bot 2026-11-18 00:15:36 +05:00
commit f976c53e91
7 changed files with 9 additions and 4 deletions

View File

@ -34,6 +34,7 @@
- BRM-118: причины недоступных кнопок (письмо, stop/resume/send на «Сводке») уже были из BRM-96/98; добавлено только title=причина у stop/resume в server.js; тесты гонять через `env -i PATH HOME npm test`.
- BRM-120: на главной причина выключенной отправки — только в списке sendBox (мелкой строки home.send.hint больше нет); время версии одно — в deployBox.
- BRM-106/110/122/125: плашка deployBox общая для главной и «Бота и отчётов»: «Обновлено: … по Алматы» + «Что нового для вас» — массив DEPLOY_NOTES в src/site.js (ключи deploy.note.*, по порядку выкладки, новое — в конец), номер истории в скобках; тест BRM-99 перечисляет допустимые номера; спеки deploy-notes нет, требования — в deploy-box.
- BRM-119: у «Возобновить отправку» без ключа бота причина — ui.sum.s.resumeWhyNoTg (не «Рассылка уже идёт»); выбирает server.js по telegram.connected() и summary.html по st.telegram.
## Команды
- BRM-13: Node без зависимостей; `npm test` (сбросить NODE_TEST_CONTEXT, иначе node:test не стартует); lint = node --check src/*.js; dist/ не трогать.

View File

@ -556,6 +556,7 @@
"ui.sum.schedOnNoTg": "Only the schedule is on: sending to Telegram is off in this version, so summaries are not delivered to Telegram.",
"ui.sum.s.stopWhy": "Sending is already stopped.",
"ui.sum.s.resumeWhy": "Sending is already running.",
"ui.sum.s.resumeWhyNoTg": "The schedule is saved, but summaries are not sent to Telegram until the team passes on the bot key. So there is nothing to resume yet.",
"ui.str.hVersions": "Strategy versions",
"ui.str.noPublishNote": "Nothing is published until the strategy is approved.",
"ui.str.fbLabel": "Comment on this version",

View File

@ -556,6 +556,7 @@
"ui.sum.schedOnNoTg": "Тек кесте қосулы: бұл нұсқада Telegram-ға жіберу өшірулі, жиынтықтар Telegram-ға жөнелтілмейді.",
"ui.sum.s.stopWhy": "Жіберу әлдеқашан тоқтатылған.",
"ui.sum.s.resumeWhy": "Жіберу әлдеқашан жүріп жатыр.",
"ui.sum.s.resumeWhyNoTg": "Кесте сақталған, бірақ команда бот кілтін бермейінше, жиынтықтар Telegram-ға жіберілмейді. Сондықтан жалғастыратын ештеңе жоқ.",
"ui.str.hVersions": "Стратегия нұсқалары",
"ui.str.noPublishNote": "Стратегия бекітілгенге дейін ештеңе жарияланбайды.",
"ui.str.fbLabel": "Нұсқаға ескерту",

View File

@ -556,6 +556,7 @@
"ui.sum.schedOnNoTg": "Включено только расписание: на этой версии отправка в Telegram выключена, сводки в Telegram не уходят.",
"ui.sum.s.stopWhy": "Рассылка уже остановлена.",
"ui.sum.s.resumeWhy": "Рассылка уже идёт.",
"ui.sum.s.resumeWhyNoTg": "Расписание сохранено, но сводки в Telegram не уходят, пока команда не передаст ключ бота. Поэтому возобновлять пока нечего.",
"ui.str.hVersions": "Версии стратегии",
"ui.str.noPublishNote": "До утверждения стратегии ничего не публикуется.",
"ui.str.fbLabel": "Замечание к версии",

View File

@ -69,7 +69,7 @@ async function loadSet(){const[,d]=await api("GET","/api/summary/settings");$("w
const[,l]=await api("GET","/api/summary/log");none($("log"),"ui.sum.logEmpty",l.map(e=>`${when(e.time)} — ${t("ui.sum.log."+(e.result==="published"?"published":e.off?"off":e.reason==="stopped"?"stopped":"failed"))}${e.text?"\n"+e.text:""}`).join("\n\n"));
const[,st]=await api("GET","/api/summary/status");$("tg").textContent=t(st.telegram?"ui.sum.tgOn":"ui.sum.tgOff")+(st.telegram||!st.missing?"":" "+t("why.tg."+st.missing));$("tg").classList.toggle("on",!!st.telegram);
PAUSED=!!st.paused;$("sched").textContent=t(PAUSED?"ui.sum.schedOff":st.telegram?"ui.sum.schedOn":"ui.sum.schedOnNoTg");
for(const[id,off,why,tip]of[["stop",PAUSED,"ui.sum.s.stopWhy","ui.sum.s.stopTip"],["resume",!PAUSED,"ui.sum.s.resumeWhy","ui.sum.s.resumeTip"]]){const e=$(id);e.classList.toggle("off",off);e.setAttribute("aria-disabled",String(off));e.title=t(off?why:tip);$(id+"why").textContent=off?t(why):""}const b=$("send");b.classList.toggle("off",!st.telegram);b.setAttribute("aria-disabled",String(!st.telegram));b.title=t(st.telegram?"ui.sum.sendTip":"ui.sum.sendOffTip");$("sendwhy").textContent=st.telegram?"":t(st.missing?"why.tg.short."+st.missing:"ui.sum.sendWhy")}
for(const[id,off,why,tip]of[["stop",PAUSED,"ui.sum.s.stopWhy","ui.sum.s.stopTip"],["resume",!PAUSED,st.telegram?"ui.sum.s.resumeWhy":"ui.sum.s.resumeWhyNoTg","ui.sum.s.resumeTip"]]){const e=$(id);e.classList.toggle("off",off);e.setAttribute("aria-disabled",String(off));e.title=t(off?why:tip);$(id+"why").textContent=off?t(why):""}const b=$("send");b.classList.toggle("off",!st.telegram);b.setAttribute("aria-disabled",String(!st.telegram));b.title=t(st.telegram?"ui.sum.sendTip":"ui.sum.sendOffTip");$("sendwhy").textContent=st.telegram?"":t(st.missing?"why.tg.short."+st.missing:"ui.sum.sendWhy")}
$("saveset").onclick=async()=>{const[ok,d]=await api("PUT","/api/summary/settings",{weekly:{day:Number($("wday").value),time:$("wtime").value},daily:{enabled:$("den").checked,time:$("dtime").value}});$("err").textContent=ok?"":d.error;$("ok").textContent=ok?t("ui.sum.s.saved"):""};
$("stop").onclick=async()=>{if(PAUSED)return;await api("POST","/api/summary/stop",{});$("ok").textContent=t("ui.sum.s.stopped");loadSet()};
$("resume").onclick=async()=>{if(!PAUSED)return;await api("POST","/api/summary/resume",{});$("ok").textContent=t("ui.sum.s.resumed");loadSet()};

View File

@ -361,7 +361,7 @@ export function createApp({ file, oppsFile, metricsFile, telegram = createTelegr
const off = Boolean(pub.status().channels.telegram?.stopped);
page = page.replace('<p id="sched" class="hint" role="status"></p>', `<p id="sched" class="hint" role="status">${t(pageLang, off ? "ui.sum.schedOff" : telegram.connected() ? "ui.sum.schedOn" : "ui.sum.schedOnNoTg")}</p>`);
page = page.replace("<table id=\"list\"></table>", metricsTable(pageLang, metrics.list()));
for (const [id, offNow, why] of [["stop", off, "ui.sum.s.stopWhy"], ["resume", !off, "ui.sum.s.resumeWhy"]]) {
for (const [id, offNow, why] of [["stop", off, "ui.sum.s.stopWhy"], ["resume", !off, telegram.connected() ? "ui.sum.s.resumeWhy" : "ui.sum.s.resumeWhyNoTg"]]) {
if (!offNow) continue;
page = page.replace(`<button id="${id}" `, `<button id="${id}" class="off" aria-disabled="true" `).replace(new RegExp(`(<button id="${id}"[^>]*?) title="[^"]*"`), `$1 title="${t(pageLang, why)}"`).replace(`<small id="${id}why"></small>`, `<small id="${id}why">${t(pageLang, why)}</small>`);
}

View File

@ -91,8 +91,9 @@ test("BRM-96: «Сводка» и письмо до скриптов показ
try {
let h = await (await fetch(base + "/summary.html")).text();
assert.match(h, /<button id="resume" class="off" aria-disabled="true"/);
assert.ok(h.includes('<small id="resumewhy">Рассылка уже идёт.</small>'));
assert.match(h, /id="resume"[^>]*title="Рассылка уже идёт\."/);
assert.ok(h.includes('<small id="resumewhy">Расписание сохранено, но сводки в Telegram не уходят, пока команда не передаст ключ бота. Поэтому возобновлять пока нечего.</small>'));
assert.ok(!h.includes("Рассылка уже идёт"));
assert.match(h, /id="resume"[^>]*title="Расписание сохранено/);
assert.match(h, /<button id="stop" data-t/, "«Остановить» доступна, причины нет");
assert.ok(h.includes('<small id="stopwhy"></small>'));
await fetch(base + "/api/summary/stop", { method: "POST", headers: { "content-type": "application/json" }, body: "{}" });