v1.4.0: 발화 우클릭 삭제(잡음이라 삭제 · 그냥 삭제) · 잡음 문장 배우기 · 새 발화/재생 시작 알림 기본 끄기

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-16 20:30:33 +09:00
parent 8047a2e948
commit 3115337706
21 changed files with 670 additions and 13 deletions

View File

@@ -117,6 +117,9 @@ function userProfile(id) {
// ── WS ───────────────────────────────────────────────
let wss;
// "잡음이라 삭제"로 배운 문장 (v1.4.0)
const noisePhrases = [{ id: 1, text: '시청해 주셔서 감사합니다 자막 제공', hits: 3, createdAt: Date.now() - 86400000 }];
let noiseSeq = 1;
const broadcast = (msg) => {
const s = JSON.stringify(msg, (k, v) => (k.startsWith('_') ? undefined : v));
wss?.clients.forEach((c) => c.readyState === 1 && c.send(s));
@@ -264,6 +267,35 @@ async function handle(req, res) {
broadcast({ type: 'utterance.updated', data: it });
return json(res, 200, it);
}
if ((m = p.match(/^\/api\/utterances\/([^/]+)\/delete$/)) && req.method === 'POST') {
const i = db.utterances.findIndex((u) => u.id === decodeURIComponent(m[1]));
if (i < 0) return json(res, 404, { error: 'not_found' });
const body = JSON.parse((await readBody(req)) || '{}');
const [it] = db.utterances.splice(i, 1);
let learned = null;
if (body.noise && it.text) {
learned = it.text;
noisePhrases.unshift({ id: ++noiseSeq, text: it.text, hits: 0, createdAt: Date.now() });
}
broadcast({ type: 'utterance.deleted', data: { id: it.id, noise: !!body.noise } });
return json(res, 200, { ok: true, learned });
}
if (p === '/api/dictionary')
return json(res, 200, {
labels: { valorant: '발로란트', lol: '롤' },
entries: [
{ id: 1, word: '로테', from: null, kind: 'hotword', pack: 'site', source: 'site', enabled: true, hits: 12 },
{ id: 2, word: '레이즈', from: '레이저', kind: 'correction', pack: 'site', source: 'site', enabled: true, hits: 0 },
],
packs: [{ key: 'valorant', label: '발로란트', count: 420 }],
});
if (p === '/api/noise-phrases') return json(res, 200, { phrases: noisePhrases });
if ((m = p.match(/^\/api\/noise-phrases\/(\d+)$/)) && req.method === 'DELETE') {
const i = noisePhrases.findIndex((x) => x.id === Number(m[1]));
if (i < 0) return json(res, 404, { error: 'not_found' });
noisePhrases.splice(i, 1);
return json(res, 200, { ok: true });
}
if (p === '/api/bundles') {
const out = [];
for (const mt of db.matches) {