From 310e91ed971c0a3ec115fd10a41fb85465975b04 Mon Sep 17 00:00:00 2001 From: oxpoe Date: Thu, 5 Nov 2026 17:08:08 +0700 Subject: [PATCH] fix(gowa): Test Koneksi pakai nilai form tanpa simpan - testReachability menerima override baseUrl/username/password - UI mengirim nilai form - versi 0.5.12 --- CHANGELOG.md | 5 +++++ README.md | 2 +- package.json | 2 +- routes/adminPortal.js | 9 +++++++-- services/gowaWhatsappService.js | 13 ++++++++++--- version.txt | 2 +- views/admin/whatsapp.ejs | 11 ++++++++++- 7 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b745c3..c24a40c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Format mengikuti [Keep a Changelog](https://keepachangelog.com/) dan [Semantic Versioning](https://semver.org/). +## [0.5.12] — 2026-11-05 — "gowa-test-unsaved" + +### Diperbaiki +- **Test Koneksi GOWA** kini memakai nilai yang sedang diisi di form (base URL, username, password), jadi tidak perlu simpan pengaturan dulu. + ## [0.5.11] — 2026-11-05 — "gowa-test" ### Ditambahkan diff --git a/README.md b/README.md index 2c1bba0..f4ab3e7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

Lisensi: ISC - Versi 0.5.11 (gowa-test) + Versi 0.5.12 (gowa-test-unsaved) Node.js >= 20 Docker Demo diff --git a/package.json b/package.json index 3fa3055..1353c1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-isp", - "version": "0.5.11", + "version": "0.5.12", "description": "OPEN-ISP \u2014 sistem billing & manajemen ISP open-source (PWA pelanggan, multi-OLT, RADIUS, WhatsApp, QRIS)", "main": "app-customer.js", "scripts": { diff --git a/routes/adminPortal.js b/routes/adminPortal.js index bb46c19..e7fab36 100644 --- a/routes/adminPortal.js +++ b/routes/adminPortal.js @@ -6770,10 +6770,15 @@ router.post('/whatsapp/gateway-settings', requireAdminSession, express.urlencode res.redirect('/admin/whatsapp'); }); -router.post('/whatsapp/test-gowa-connection', requireAdminSession, async (req, res) => { +router.post('/whatsapp/test-gowa-connection', requireAdminSession, express.json(), async (req, res) => { try { const gowaSvc = require('../services/gowaWhatsappService'); - const r = await gowaSvc.testReachability(); + const b = req.body || {}; + const r = await gowaSvc.testReachability({ + baseUrl: b.gowa_base_url, + username: b.gowa_username, + password: b.gowa_password + }); return res.json(Object.assign({ ok: r.reachable, success: r.reachable }, r)); } catch (e) { return res.status(500).json({ ok: false, success: false, message: e.message }); diff --git a/services/gowaWhatsappService.js b/services/gowaWhatsappService.js index ad8a783..c585bc6 100644 --- a/services/gowaWhatsappService.js +++ b/services/gowaWhatsappService.js @@ -131,8 +131,15 @@ async function sendGowaDocument(toPhone, documentBuffer, filename = 'file.pdf', }); return { success: true, gateway: 'gowa', raw: json }; } -async function testReachability() { - const base = baseUrl(); +async function testReachability(opts = {}) { + // Nilai form boleh dipakai tanpa menyimpan pengaturan lebih dulu. + const base = String(opts.baseUrl || baseUrl()).trim().replace(/\/+$/, '') || baseUrl(); + const headers = {}; + if (opts.username && opts.password) { + headers.Authorization = 'Basic ' + Buffer.from(opts.username + ':' + opts.password).toString('base64'); + } else { + Object.assign(headers, commonHeaders()); + } const out = { baseUrl: base, reachable: false, healthStatus: 0, authOk: false, devices: 0, message: '' }; try { const res = await fetch(base + '/health'); @@ -147,7 +154,7 @@ async function testReachability() { return out; } try { - const res = await fetch(base + '/devices', { headers: commonHeaders() }); + const res = await fetch(base + '/devices', { headers: headers }); out.authStatus = res.status; const json = await res.json().catch(function () { return null; }); const list = (json && Array.isArray(json.results)) ? json.results : []; diff --git a/version.txt b/version.txt index cacdf3b..12697f7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.5.11 \ No newline at end of file +0.5.12 \ No newline at end of file diff --git a/views/admin/whatsapp.ejs b/views/admin/whatsapp.ejs index 062af52..90d2bc9 100644 --- a/views/admin/whatsapp.ejs +++ b/views/admin/whatsapp.ejs @@ -245,7 +245,16 @@ if (btn) { btn.disabled = true; btn.innerHTML = ' Menguji...'; } if (el) { el.style.display = 'block'; el.style.color = 'var(--muted)'; el.textContent = 'Menghubungi ' + (document.querySelector('input[name="gowa_base_url"]') || {}).value + ' ...'; } try { - var r = await fetch('/admin/whatsapp/test-gowa-connection', { method: 'POST' }); + var payload = { + gowa_base_url: (document.querySelector('input[name="gowa_base_url"]') || {}).value || '', + gowa_username: (document.querySelector('input[name="gowa_username"]') || {}).value || '', + gowa_password: (document.querySelector('input[name="gowa_password"]') || {}).value || '' + }; + var r = await fetch('/admin/whatsapp/test-gowa-connection', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(payload) + }); var d = await r.json(); if (el) { el.textContent = d.message || (d.ok ? 'GOWA terjangkau.' : 'GOWA tidak terjangkau.');