forked from admin/zeropost-engine
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:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user