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
+18 -2
View File
@@ -325,10 +325,26 @@ async function publishOne(scheduledPost) {
// imgSource === 'none' → photoUrl остаётся null
}
if (!text) throw new Error('Empty text and no article');
if (!text && scheduledPost.post_type !== 'poll') throw new Error('Empty text and no article');
let messageId;
if (channel.platform === 'telegram' || !channel.platform) {
// Опрос — отдельная ветка
if (scheduledPost.post_type === 'poll') {
if (channel.platform !== 'telegram') throw new Error('Опросы только в Telegram');
const { sendPoll } = require('../routes/polls');
const meta = scheduledPost.meta || {};
messageId = await sendPoll({
channel,
question: meta.question || scheduledPost.text,
options: meta.options || [],
is_anonymous: meta.is_anonymous ?? true,
allows_multiple_answers: meta.allows_multiple_answers ?? false,
type: meta.type || 'regular',
correct_option_id: meta.correct_option_id,
explanation: meta.explanation,
});
} else if (channel.platform === 'telegram' || !channel.platform) {
messageId = await publishToTelegram({ channel, text, photoUrl, article });
} else if (channel.platform === 'vk') {
messageId = await publishToVK({ channel, text, photoUrl, article });