feat: P6 inbox — TG webhook + AI classify + reply

DB: inbox_messages (text, ai_type, ai_reply, status), channels.tg_webhook_enabled
Engine routes/inbox.js:
  POST /api/tg-webhook/:channelId — получаем комментарии от TG (публичный)
  GET  /api/inbox/:channelId      — список сообщений с фильтром
  GET  /api/inbox/stats/:channelId — статистика по типам
  POST /api/inbox/:id/reply       — отправить ответ в TG
  POST /api/inbox/:id/status      — изменить статус
  POST /api/inbox/:channelId/setup-webhook — зарегистрировать TG webhook
AI: claude haiku → {type, reply} JSON
This commit is contained in:
Ник (Claude)
2026-06-11 20:12:19 +03:00
parent ee63172e08
commit 10c138aa33
2 changed files with 265 additions and 0 deletions
+5
View File
@@ -56,6 +56,10 @@ app.post('/api/billing/webhook',
})
);
// TG webhook — публичный (TG не шлёт internal secret)
const inboxRoutes = require('./src/routes/inbox');
app.use('/api', inboxRoutes); // включает /api/tg-webhook/:channelId
// Simple internal auth middleware
app.use((req, res, next) => {
const secret = req.headers['x-internal-secret'];
@@ -102,6 +106,7 @@ app.use('/api/metrics', metricsRoutes);
app.use('/api/usage', usageRoutes);
app.use('/api/billing', require('./src/routes/billing'));
app.use('/api/channels', require('./src/routes/polls'));
app.use('/api', inboxRoutes); // /inbox/:id, /inbox/:id/reply, /tg-webhook/:channelId
app.get('/health', (req, res) => {
res.json({ ok: true, service: 'zeropost-engine', time: new Date() });