Fix archive missing on manual publish; refresh VK token instructions
- Mark scheduled post as 'published' instead of deleting it when user clicks "Опубликовать сейчас", so it appears in the archive (parity with cron path) - Surface VK warnings (e.g. photos posted as links when community token lacks photos right) in both the post-publish notification and the archive card - Replace dead vkhost.github.io / VK Admin instructions with a community-token flow via group settings, since VK now blocks the old app (error 8) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -776,6 +776,43 @@ try {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'mark_post_published':
|
||||
$scheduledFile = __DIR__ . '/data/scheduled_posts.json';
|
||||
$postId = $_POST['id'] ?? '';
|
||||
$resultsJson = $_POST['results'] ?? '{}';
|
||||
$results = json_decode($resultsJson, true) ?: [];
|
||||
|
||||
if (!$postId) {
|
||||
echo json_encode(['error' => 'ID поста не указан']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$posts = file_exists($scheduledFile) ? json_decode(file_get_contents($scheduledFile), true) ?: [] : [];
|
||||
$found = false;
|
||||
|
||||
foreach ($posts as &$post) {
|
||||
if (($post['id'] ?? null) === $postId && ($post['status'] ?? '') === 'pending') {
|
||||
$post['status'] = 'published';
|
||||
$post['published_at'] = date('Y-m-d H:i:s');
|
||||
$post['results'] = $results;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($post);
|
||||
|
||||
if (!$found) {
|
||||
echo json_encode(['error' => 'Пост не найден или уже опубликован']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (file_put_contents($scheduledFile, json_encode($posts, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) {
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['error' => 'Не удалось сохранить']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'get_published_posts':
|
||||
$scheduledFile = __DIR__ . '/data/scheduled_posts.json';
|
||||
if (file_exists($scheduledFile)) {
|
||||
|
||||
Reference in New Issue
Block a user