Commit Graph

7 Commits

Author SHA1 Message Date
Ник (Claude) c40ef90ad1 feat: SMTP, maintenance mode, blog topic bank UI
8. SMTP: emailService.js (nodemailer), templates (welcome/payment/low_credits)
   /api/admin/email/test — тест отправки
   app_settings category=smtp (HOST/PORT/USER/PASS/FROM/ENABLED)
9. Maintenance mode: middleware в index.js, MAINTENANCE_MODE в engine settings
   При true → 503 для всех запросов кроме /uploads и /api/settings
10. Blog topic bank:
   DB: blog_topics(category,topic,is_used,source,priority)
   40 тем мигрированы из хардкода (source=hardcoded)
   autogen.js: getNextTopic берёт из DB, fallback на TOPIC_BANK
   admin API: GET/POST /blog-topics, DELETE /:id, POST /generate (AI +10)
2026-06-13 11:45:23 +03:00
Ник (Claude) b5fa77ea01 feat: autogen blog admin API
routes/admin.js:
  GET  /autogen — настройки+статистика+очередь+размеры банков тем
  PATCH /autogen/:category — enabled/per_day/run_hour/run_minute
  POST  /autogen/:category/run — ручной запуск генерации
  POST  /autogen/queue — добавить тему с приоритетом
  DELETE /autogen/queue/:id — удалить тему
2026-06-13 10:35:50 +03:00
Ник (Claude) 6e1cd24b4e feat: error logs API
routes/admin.js: GET /logs — объединённые ошибки из 3 источников:
  generation_jobs (status=failed), ai_usage (!succeeded), scheduled_posts (status=failed)
  Сортировка по времени, топ-5 частых ошибок, группировка по типу
2026-06-13 10:23:24 +03:00
Ник (Claude) 7994b0e73c feat: generation queue admin
routes/admin.js: GET /queue (stats+recent30+stuck), POST /queue/:id/retry, DELETE /queue/stuck
  stuck = processing > 5 min → сбрасываем в failed
  retry = pending + requeue через Bull
2026-06-13 10:13:21 +03:00
Ник (Claude) ce74ac9909 feat: promo codes system
DB: promo_codes, promo_usages tables
routes/admin.js: CRUD /api/admin/promos (GET/POST/PATCH/DELETE)
routes/billing.js: POST /api/billing/apply-promo
  Валидация: exists, active, not expired, not exhausted, not used by this user
  type=credits → начисляет через billing.credit()
2026-06-13 09:36:32 +03:00
Ник (Claude) 05fa7644cc feat: user management — detail view, block/unblock, plan change
routes/admin.js: GET /users/:id (profile+channels+balance+transactions)
  PATCH /users/:id (is_blocked, plan_code, name)
  plan change: cancels active sub → creates new → credits reset
generate.js: check is_blocked before generation → 403 ACCOUNT_BLOCKED
DB: users.is_blocked BOOLEAN DEFAULT false
2026-06-13 00:14:11 +03:00
Ник (Claude) f18b83c59b feat: admin dashboard API + separate admin routes file
routes/admin.js: GET /dashboard, /users, POST /credit, PATCH /plans/:id, /credit-costs/:op
index.js: app.use('/api/admin', adminRoutes) — чистый монтаж без хаков
dashboard: users (total/7d/30d), channels by platform, posts (total/today/week),
  revenue (YuKassa), AI costs (30d), registrations chart (14d), pending drafts alert
2026-06-13 00:09:53 +03:00