feat: make group sync interval configurable via env var

main
borja (aider) 3 months ago
parent ed7b209c1b
commit 73fdf950dd

@ -6,3 +6,7 @@ WHATSAPP_COMMUNITY_ID="example-community-id@g.us"
CHATBOT_PHONE_NUMBER="1234567890"
PORT="3007"
WEBHOOK_URL="https://example-url.com/webhook"
# Group sync interval in milliseconds (default: 24h)
# Set lower during development (e.g. 60000 = 1 minute)
# GROUP_SYNC_INTERVAL_MS=86400000

@ -10,7 +10,18 @@ type EvolutionGroup = {
};
export class GroupSyncService {
private static readonly SYNC_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24 hours
private static get SYNC_INTERVAL_MS(): number {
const interval = process.env.GROUP_SYNC_INTERVAL_MS
? Number(process.env.GROUP_SYNC_INTERVAL_MS)
: 24 * 60 * 60 * 1000; // Default 24 hours
// Ensure minimum 10 second interval in development
if (process.env.NODE_ENV === 'development' && interval < 10000) {
console.warn(`Sync interval too low (${interval}ms), using 10s minimum`);
return 10000;
}
return interval;
}
private static lastSyncAttempt = 0;
static async syncGroups(): Promise<{ added: number; updated: number }> {

Loading…
Cancel
Save