From cb60ceec102fbf72c1e236b481cf6bde8e92441d Mon Sep 17 00:00:00 2001 From: oxpoe Date: Tue, 13 Oct 2026 03:47:32 +0700 Subject: [PATCH] chore: default wa_gateway_type=gowa (baileys dilepas) + README --- README.md | 2 +- app-customer.js | 2 +- config/database.js | 2 +- routes/adminPortal.js | 6 +++--- routes/customerAPI.js | 2 +- services/cronService.js | 2 +- services/diagnosticsService.js | 2 +- services/waNotifyService.js | 2 +- services/whatsappBot.mjs | 16 ++++++++-------- services/whatsappService.js | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index bea60d9..8a82962 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Dukungan sukarela tetap diterima lewat menu **Dukung OPEN-ISP** di aplikasi. ## Teknologi -Node.js · Express · EJS · better-sqlite3 (SQLite) · Bootstrap 5 + Bootstrap Icons (vendor lokal) · Leaflet · PWA/Service Worker · sharp · net-snmp · MikroTik RouterOS API · Baileys / GoWA · Telegram Bot API. +Node.js · Express · EJS · better-sqlite3 (SQLite) · Bootstrap 5 + Bootstrap Icons (vendor lokal) · Leaflet · PWA/Service Worker · sharp · net-snmp · MikroTik RouterOS API · GoWA (WhatsApp gateway) · Telegram Bot API. ## Lisensi & Kredit diff --git a/app-customer.js b/app-customer.js index 204cec7..02935b4 100644 --- a/app-customer.js +++ b/app-customer.js @@ -2211,7 +2211,7 @@ logger.info(`Attempting to start server on configured port: ${port}`); startServer(port); if (getSetting('whatsapp_enabled', false)) { - const gwType = getSetting('wa_gateway_type', 'baileys'); + const gwType = getSetting('wa_gateway_type', 'gowa'); if (gwType === 'baileys') { import('./services/whatsappBot.mjs') .then((mod) => mod.startWhatsAppBot()) diff --git a/config/database.js b/config/database.js index ea9c2a9..78b2718 100644 --- a/config/database.js +++ b/config/database.js @@ -464,7 +464,7 @@ db.exec(` CREATE TABLE IF NOT EXISTS wa_chat_messages ( id INTEGER PRIMARY KEY AUTOINCREMENT, direction TEXT NOT NULL DEFAULT 'outbound', - gateway TEXT NOT NULL DEFAULT 'baileys', + gateway TEXT NOT NULL DEFAULT 'gowa', sender_phone TEXT, recipient_phone TEXT, customer_id INTEGER REFERENCES customers(id) ON DELETE SET NULL, diff --git a/routes/adminPortal.js b/routes/adminPortal.js index 3e9d00b..7d6479d 100644 --- a/routes/adminPortal.js +++ b/routes/adminPortal.js @@ -6496,7 +6496,7 @@ router.get('/whatsapp/gowa/qr.png', requireAdminSession, async (req, res) => { }); router.get('/whatsapp', requireAdminSession, requireSidebarMenuAccess('whatsapp'), async (req, res) => { - const waGatewayType = getSetting('wa_gateway_type', 'baileys'); + const waGatewayType = getSetting('wa_gateway_type', 'gowa'); const metaSettings = { meta_phone_number_id: getSetting('meta_phone_number_id', ''), meta_waba_id: getSetting('meta_waba_id', ''), @@ -6611,7 +6611,7 @@ router.post('/whatsapp/test-fonnte', requireAdminSession, express.json(), async // LIVE CHAT ROUTES router.get('/whatsapp/live-chat', requireAdminSession, requireSidebarMenuAccess('whatsapp'), async (req, res) => { - const waGatewayType = getSetting('wa_gateway_type', 'baileys'); + const waGatewayType = getSetting('wa_gateway_type', 'gowa'); const customers = customerSvc.getAllCustomers(); res.render('admin/whatsapp_live_chat', { title: 'Live Chat WhatsApp', @@ -7075,7 +7075,7 @@ router.post('/whatsapp/run-reminder-now', requireAdminSession, async (req, res) router.get('/api/whatsapp/status', requireAdmin, async (req, res) => { try { - const gatewayType = getSetting('wa_gateway_type', 'baileys'); + const gatewayType = getSetting('wa_gateway_type', 'gowa'); if (gatewayType === 'fonnte') { const token = getSetting('fonnte_token', ''); res.json({ diff --git a/routes/customerAPI.js b/routes/customerAPI.js index 9f3818b..7cdb3fe 100644 --- a/routes/customerAPI.js +++ b/routes/customerAPI.js @@ -2088,7 +2088,7 @@ router.get('/app/admin/olts', requireAdminApiAuth, (req, res) => { // ─── ADMIN NATIVE: WHATSAPP STATUS ─────────────────────────────────────────── router.get('/app/admin/whatsapp/status', requireAdminApiAuth, async (req, res) => { try { - const gwType = String(require('../config/settingsManager').getSetting('wa_gateway_type', 'baileys') || 'baileys').toLowerCase(); + const gwType = String(require('../config/settingsManager').getSetting('wa_gateway_type', 'gowa') || 'baileys').toLowerCase(); let isConnected = false; let waNumber = '-'; let waName = gwType.toUpperCase(); diff --git a/services/cronService.js b/services/cronService.js index 0c4a664..63b0efc 100644 --- a/services/cronService.js +++ b/services/cronService.js @@ -62,7 +62,7 @@ async function runAutoBillingReminder() { const billingEnabled = getSetting('whatsapp_billing_to_customer_enabled', true); if (!enabled || !waEnabled || !billingEnabled) return { target: 0, sent: 0, failed: 0, skipped: 'disabled' }; - const gatewayType = getSetting('wa_gateway_type', 'baileys'); + const gatewayType = getSetting('wa_gateway_type', 'gowa'); const waSvc = require('./whatsappService'); if (gatewayType === 'meta') { diff --git a/services/diagnosticsService.js b/services/diagnosticsService.js index 7212b52..8b3498e 100644 --- a/services/diagnosticsService.js +++ b/services/diagnosticsService.js @@ -108,7 +108,7 @@ async function checkDependencies() { // 3. Check WhatsApp Gateway (GoWA / Baileys sesuai setting wa_gateway_type) try { const { getSetting } = require('../config/settingsManager'); - const gw = String(getSetting('wa_gateway_type', 'baileys') || 'baileys').toLowerCase(); + const gw = String(getSetting('wa_gateway_type', 'gowa') || 'baileys').toLowerCase(); if (gw === 'gowa') { const base = String(getSetting('gowa_base_url', 'http://127.0.0.1:3000') || '').replace(/\/+$/, ''); const u = getSetting('gowa_username', ''); diff --git a/services/waNotifyService.js b/services/waNotifyService.js index c6814f6..805fd9c 100644 --- a/services/waNotifyService.js +++ b/services/waNotifyService.js @@ -8,7 +8,7 @@ const path = require('path'); const { getSetting } = require('../config/settingsManager'); function gateway() { - return String(getSetting('wa_gateway_type', 'baileys') || 'baileys').toLowerCase(); + return String(getSetting('wa_gateway_type', 'gowa') || 'baileys').toLowerCase(); } function spx(t) { diff --git a/services/whatsappBot.mjs b/services/whatsappBot.mjs index 4327747..a56a0fb 100644 --- a/services/whatsappBot.mjs +++ b/services/whatsappBot.mjs @@ -933,7 +933,7 @@ export const whatsappStatus = { _connection: 'connecting', get connection() { try { - const gw = getSetting('wa_gateway_type', 'baileys'); + const gw = getSetting('wa_gateway_type', 'gowa'); if (gw === 'fonnte') { const token = getSetting('fonnte_token', ''); return token ? 'open' : 'close'; @@ -954,7 +954,7 @@ export const whatsappStatus = { _user: null, get user() { try { - const gw = getSetting('wa_gateway_type', 'baileys'); + const gw = getSetting('wa_gateway_type', 'gowa'); if (gw === 'fonnte') { return { id: 'fonnte_gateway', name: 'Fonnte Gateway' }; } @@ -973,7 +973,7 @@ export const whatsappStatus = { _phoneNumber: null, get phoneNumber() { try { - const gw = getSetting('wa_gateway_type', 'baileys'); + const gw = getSetting('wa_gateway_type', 'gowa'); if (gw === 'fonnte') return 'Fonnte Gateway'; if (gw === 'meta') return getSetting('meta_phone_number_id', 'Meta API'); if (gw === 'gowa') return getSetting('gowa_device_id', '') || 'GOWA Gateway'; @@ -986,7 +986,7 @@ export const whatsappStatus = { _pushName: null, get pushName() { try { - const gw = getSetting('wa_gateway_type', 'baileys'); + const gw = getSetting('wa_gateway_type', 'gowa'); if (gw === 'fonnte') return 'Fonnte Gateway'; if (gw === 'meta') return 'Meta Cloud API'; if (gw === 'gowa') return 'GOWA Gateway'; @@ -1032,7 +1032,7 @@ function loadWhatsappAdminSendList() { * @param {string} priority - Priority level: 'high', 'medium', 'low' */ export async function sendMonitoringAlert(message, priority = 'medium') { - const gatewayType = getSetting('wa_gateway_type', 'baileys'); + const gatewayType = getSetting('wa_gateway_type', 'gowa'); if (gatewayType === 'baileys' && (!currentSock || whatsappStatus._connection !== 'open')) { logger.warn('[WhatsApp] Bot belum siap (koneksi belum terbuka), tidak dapat mengirim alert monitoring'); return { success: false, message: 'Bot belum siap' }; @@ -1139,7 +1139,7 @@ export async function simulateHumanTyping(sock, jid, text = '') { } export async function sendWA(to, text, options = {}) { - const gatewayType = getSetting('wa_gateway_type', 'baileys'); + const gatewayType = getSetting('wa_gateway_type', 'gowa'); let finalText = text; if (options.spintax !== false && typeof text === 'string' && text.includes('{') && text.includes('}')) { @@ -1219,7 +1219,7 @@ export async function sendWA(to, text, options = {}) { } export async function sendWAImage(to, imageBuffer, caption = '', options = {}) { - const gatewayType = getSetting('wa_gateway_type', 'baileys'); + const gatewayType = getSetting('wa_gateway_type', 'gowa'); let finalCaption = caption; if (options.spintax !== false && typeof caption === 'string' && caption.includes('{') && caption.includes('}')) { @@ -1286,7 +1286,7 @@ export async function sendWAImage(to, imageBuffer, caption = '', options = {}) { } export async function sendWADocument(to, documentBuffer, filename = 'Invoice.pdf', caption = '', mimetype = 'application/pdf', options = {}) { - const gatewayType = getSetting('wa_gateway_type', 'baileys'); + const gatewayType = getSetting('wa_gateway_type', 'gowa'); let finalCaption = caption; if (options.spintax !== false && typeof caption === 'string' && caption.includes('{') && caption.includes('}')) { diff --git a/services/whatsappService.js b/services/whatsappService.js index 3c2be87..120d215 100644 --- a/services/whatsappService.js +++ b/services/whatsappService.js @@ -140,7 +140,7 @@ function formatUnpaidInvoicesSummary(unpaidInvoices) { * @param {object} options Opsi tambahan: { templateName, parameters, langCode, url, filename } */ async function sendWhatsAppMessage(toPhone, messageText, options = {}) { - const gatewayType = getSetting('wa_gateway_type', 'baileys'); // 'baileys', 'fonnte', or 'meta' + const gatewayType = getSetting('wa_gateway_type', 'gowa'); // 'baileys', 'fonnte', or 'meta' if (gatewayType === 'fonnte') { // Mode FONNTE API GATEWAY (Cloud / Self-Hosted)