feat: P7 polls + P8 hashtags

P7 — Опросы в Telegram:
- routes/polls.js: POST /api/channels/:id/poll (sendPoll + schedule support)
- DB: scheduled_posts.post_type + meta для отложенных опросов
- scheduledPostsRunner: обработка post_type='poll' через sendPoll
- index.js: роут /api/channels подключён

P8 — Хештеги:
- ai.js: generateHashtags() через Claude Haiku, JSON-массив тегов
- routes/generate.js: POST /api/generate/hashtags
This commit is contained in:
Ник (Claude)
2026-06-11 19:54:31 +03:00
parent 0a9d886435
commit 6e32241fe8
5 changed files with 170 additions and 2 deletions
+14
View File
@@ -117,6 +117,20 @@ router.get('/image-styles', async (_, res) => {
});
// POST /api/generate/topics-ideas — синхронные идеи тем для канала
router.post('/hashtags', async (req, res) => {
try {
const { channelId, postText, count = 8 } = req.body;
const userId = req.headers['x-user-id'] ? parseInt(req.headers['x-user-id']) : null;
if (!postText?.trim()) return res.status(400).json({ error: 'postText обязателен' });
const channel = channelId ? await channelsSvc.getChannel(channelId, userId) : null;
const ai = require('../services/ai');
const tags = await ai.generateHashtags(channel, { postText, count });
res.json({ hashtags: tags });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
router.post('/topics-ideas', async (req, res) => {
try {
const { channelId, count = 7 } = req.body;