chore: default wa_gateway_type=gowa (baileys dilepas) + README

This commit is contained in:
oxpoe committed 2026-10-13 03:47:32 +07:00
1 parent 0f612df70f
commit cb60ceec10
10 files changed
+19 -19

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@ Dukungan sukarela tetap diterima lewat menu **Dukung OPEN-ISP** di aplikasi.
## Teknologi ## 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 ## Lisensi & Kredit
+1 -1
View File
@@ -2211,7 +2211,7 @@ logger.info(`Attempting to start server on configured port: ${port}`);
startServer(port); startServer(port);
if (getSetting('whatsapp_enabled', false)) { if (getSetting('whatsapp_enabled', false)) {
const gwType = getSetting('wa_gateway_type', 'baileys'); const gwType = getSetting('wa_gateway_type', 'gowa');
if (gwType === 'baileys') { if (gwType === 'baileys') {
import('./services/whatsappBot.mjs') import('./services/whatsappBot.mjs')
.then((mod) => mod.startWhatsAppBot()) .then((mod) => mod.startWhatsAppBot())
+1 -1
View File
@@ -464,7 +464,7 @@ db.exec(`
CREATE TABLE IF NOT EXISTS wa_chat_messages ( CREATE TABLE IF NOT EXISTS wa_chat_messages (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
direction TEXT NOT NULL DEFAULT 'outbound', direction TEXT NOT NULL DEFAULT 'outbound',
gateway TEXT NOT NULL DEFAULT 'baileys', gateway TEXT NOT NULL DEFAULT 'gowa',
sender_phone TEXT, sender_phone TEXT,
recipient_phone TEXT, recipient_phone TEXT,
customer_id INTEGER REFERENCES customers(id) ON DELETE SET NULL, customer_id INTEGER REFERENCES customers(id) ON DELETE SET NULL,
+3 -3
View File
@@ -6496,7 +6496,7 @@ router.get('/whatsapp/gowa/qr.png', requireAdminSession, async (req, res) => {
}); });
router.get('/whatsapp', requireAdminSession, requireSidebarMenuAccess('whatsapp'), 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 = { const metaSettings = {
meta_phone_number_id: getSetting('meta_phone_number_id', ''), meta_phone_number_id: getSetting('meta_phone_number_id', ''),
meta_waba_id: getSetting('meta_waba_id', ''), meta_waba_id: getSetting('meta_waba_id', ''),
@@ -6611,7 +6611,7 @@ router.post('/whatsapp/test-fonnte', requireAdminSession, express.json(), async
// LIVE CHAT ROUTES // LIVE CHAT ROUTES
router.get('/whatsapp/live-chat', requireAdminSession, requireSidebarMenuAccess('whatsapp'), async (req, res) => { 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(); const customers = customerSvc.getAllCustomers();
res.render('admin/whatsapp_live_chat', { res.render('admin/whatsapp_live_chat', {
title: 'Live Chat WhatsApp', 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) => { router.get('/api/whatsapp/status', requireAdmin, async (req, res) => {
try { try {
const gatewayType = getSetting('wa_gateway_type', 'baileys'); const gatewayType = getSetting('wa_gateway_type', 'gowa');
if (gatewayType === 'fonnte') { if (gatewayType === 'fonnte') {
const token = getSetting('fonnte_token', ''); const token = getSetting('fonnte_token', '');
res.json({ res.json({
+1 -1
View File
@@ -2088,7 +2088,7 @@ router.get('/app/admin/olts', requireAdminApiAuth, (req, res) => {
// ─── ADMIN NATIVE: WHATSAPP STATUS ─────────────────────────────────────────── // ─── ADMIN NATIVE: WHATSAPP STATUS ───────────────────────────────────────────
router.get('/app/admin/whatsapp/status', requireAdminApiAuth, async (req, res) => { router.get('/app/admin/whatsapp/status', requireAdminApiAuth, async (req, res) => {
try { 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 isConnected = false;
let waNumber = '-'; let waNumber = '-';
let waName = gwType.toUpperCase(); let waName = gwType.toUpperCase();
+1 -1
View File
@@ -62,7 +62,7 @@ async function runAutoBillingReminder() {
const billingEnabled = getSetting('whatsapp_billing_to_customer_enabled', true); const billingEnabled = getSetting('whatsapp_billing_to_customer_enabled', true);
if (!enabled || !waEnabled || !billingEnabled) return { target: 0, sent: 0, failed: 0, skipped: 'disabled' }; 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'); const waSvc = require('./whatsappService');
if (gatewayType === 'meta') { if (gatewayType === 'meta') {
+1 -1
View File
@@ -108,7 +108,7 @@ async function checkDependencies() {
// 3. Check WhatsApp Gateway (GoWA / Baileys sesuai setting wa_gateway_type) // 3. Check WhatsApp Gateway (GoWA / Baileys sesuai setting wa_gateway_type)
try { try {
const { getSetting } = require('../config/settingsManager'); 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') { if (gw === 'gowa') {
const base = String(getSetting('gowa_base_url', 'http://127.0.0.1:3000') || '').replace(/\/+$/, ''); const base = String(getSetting('gowa_base_url', 'http://127.0.0.1:3000') || '').replace(/\/+$/, '');
const u = getSetting('gowa_username', ''); const u = getSetting('gowa_username', '');
+1 -1
View File
@@ -8,7 +8,7 @@ const path = require('path');
const { getSetting } = require('../config/settingsManager'); const { getSetting } = require('../config/settingsManager');
function gateway() { function gateway() {
return String(getSetting('wa_gateway_type', 'baileys') || 'baileys').toLowerCase(); return String(getSetting('wa_gateway_type', 'gowa') || 'baileys').toLowerCase();
} }
function spx(t) { function spx(t) {
+8 -8
View File
@@ -933,7 +933,7 @@ export const whatsappStatus = {
_connection: 'connecting', _connection: 'connecting',
get connection() { get connection() {
try { try {
const gw = getSetting('wa_gateway_type', 'baileys'); const gw = getSetting('wa_gateway_type', 'gowa');
if (gw === 'fonnte') { if (gw === 'fonnte') {
const token = getSetting('fonnte_token', ''); const token = getSetting('fonnte_token', '');
return token ? 'open' : 'close'; return token ? 'open' : 'close';
@@ -954,7 +954,7 @@ export const whatsappStatus = {
_user: null, _user: null,
get user() { get user() {
try { try {
const gw = getSetting('wa_gateway_type', 'baileys'); const gw = getSetting('wa_gateway_type', 'gowa');
if (gw === 'fonnte') { if (gw === 'fonnte') {
return { id: 'fonnte_gateway', name: 'Fonnte Gateway' }; return { id: 'fonnte_gateway', name: 'Fonnte Gateway' };
} }
@@ -973,7 +973,7 @@ export const whatsappStatus = {
_phoneNumber: null, _phoneNumber: null,
get phoneNumber() { get phoneNumber() {
try { try {
const gw = getSetting('wa_gateway_type', 'baileys'); const gw = getSetting('wa_gateway_type', 'gowa');
if (gw === 'fonnte') return 'Fonnte Gateway'; if (gw === 'fonnte') return 'Fonnte Gateway';
if (gw === 'meta') return getSetting('meta_phone_number_id', 'Meta API'); if (gw === 'meta') return getSetting('meta_phone_number_id', 'Meta API');
if (gw === 'gowa') return getSetting('gowa_device_id', '') || 'GOWA Gateway'; if (gw === 'gowa') return getSetting('gowa_device_id', '') || 'GOWA Gateway';
@@ -986,7 +986,7 @@ export const whatsappStatus = {
_pushName: null, _pushName: null,
get pushName() { get pushName() {
try { try {
const gw = getSetting('wa_gateway_type', 'baileys'); const gw = getSetting('wa_gateway_type', 'gowa');
if (gw === 'fonnte') return 'Fonnte Gateway'; if (gw === 'fonnte') return 'Fonnte Gateway';
if (gw === 'meta') return 'Meta Cloud API'; if (gw === 'meta') return 'Meta Cloud API';
if (gw === 'gowa') return 'GOWA Gateway'; if (gw === 'gowa') return 'GOWA Gateway';
@@ -1032,7 +1032,7 @@ function loadWhatsappAdminSendList() {
* @param {string} priority - Priority level: 'high', 'medium', 'low' * @param {string} priority - Priority level: 'high', 'medium', 'low'
*/ */
export async function sendMonitoringAlert(message, priority = 'medium') { 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')) { if (gatewayType === 'baileys' && (!currentSock || whatsappStatus._connection !== 'open')) {
logger.warn('[WhatsApp] Bot belum siap (koneksi belum terbuka), tidak dapat mengirim alert monitoring'); logger.warn('[WhatsApp] Bot belum siap (koneksi belum terbuka), tidak dapat mengirim alert monitoring');
return { success: false, message: 'Bot belum siap' }; 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 = {}) { export async function sendWA(to, text, options = {}) {
const gatewayType = getSetting('wa_gateway_type', 'baileys'); const gatewayType = getSetting('wa_gateway_type', 'gowa');
let finalText = text; let finalText = text;
if (options.spintax !== false && typeof text === 'string' && text.includes('{') && text.includes('}')) { 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 = {}) { 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; let finalCaption = caption;
if (options.spintax !== false && typeof caption === 'string' && caption.includes('{') && caption.includes('}')) { 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 = {}) { 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; let finalCaption = caption;
if (options.spintax !== false && typeof caption === 'string' && caption.includes('{') && caption.includes('}')) { if (options.spintax !== false && typeof caption === 'string' && caption.includes('{') && caption.includes('}')) {
+1 -1
View File
@@ -140,7 +140,7 @@ function formatUnpaidInvoicesSummary(unpaidInvoices) {
* @param {object} options Opsi tambahan: { templateName, parameters, langCode, url, filename } * @param {object} options Opsi tambahan: { templateName, parameters, langCode, url, filename }
*/ */
async function sendWhatsAppMessage(toPhone, messageText, options = {}) { 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') { if (gatewayType === 'fonnte') {
// Mode FONNTE API GATEWAY (Cloud / Self-Hosted) // Mode FONNTE API GATEWAY (Cloud / Self-Hosted)