-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-queue-to-file.mjs
More file actions
executable file
·56 lines (46 loc) · 1.8 KB
/
sync-queue-to-file.mjs
File metadata and controls
executable file
·56 lines (46 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
/**
* Sync MaxiSuite localStorage queue to file for cron scheduler
* This bridges the gap between browser UI and server-side posting
*/
import { writeFileSync } from 'fs';
import { resolve } from 'path';
const QUEUE_FILE = resolve(process.env.HOME, '.openclaw/workspace/maxisuite-queue.json');
// This will be populated by the full campaign data
import { fullCampaignData } from './js/auto-import-full-campaign.js';
function generateQueueFromCampaign() {
const queue = [];
const now = new Date();
fullCampaignData.forEach(post => {
const scheduledFor = `${post.date}T${post.time}:00-06:00`; // CST
const scheduledDate = new Date(scheduledFor);
const hoursPast = (now - scheduledDate) / (1000 * 60 * 60);
// Determine status
const isPosted = hoursPast > 1;
queue.push({
id: 'post_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9),
content: post.content,
platforms: post.platforms,
scheduledFor: scheduledFor,
requiresApproval: false,
status: isPosted ? 'posted' : 'scheduled',
createdAt: new Date().toISOString(),
postedAt: isPosted ? scheduledFor : null,
account: post.account,
contentType: post.type
});
});
return queue;
}
// Generate and save
const queue = generateQueueFromCampaign();
writeFileSync(QUEUE_FILE, JSON.stringify(queue, null, 2));
console.log(`✅ Synced ${queue.length} posts to ${QUEUE_FILE}`);
console.log(`📊 Status breakdown:`);
const statusCounts = {};
queue.forEach(p => {
statusCounts[p.status] = (statusCounts[p.status] || 0) + 1;
});
Object.entries(statusCounts).forEach(([status, count]) => {
console.log(` ${status}: ${count}`);
});