fix(gowa): Test Koneksi pakai nilai form tanpa simpan
All checks were successful
CI / test (push) Successful in 2m42s
All checks were successful
CI / test (push) Successful in 2m42s
- testReachability menerima override baseUrl/username/password - UI mengirim nilai form - versi 0.5.12
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
Format mengikuti [Keep a Changelog](https://keepachangelog.com/) dan [Semantic Versioning](https://semver.org/).
|
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"
|
## [0.5.11] — 2026-11-05 — "gowa-test"
|
||||||
|
|
||||||
### Ditambahkan
|
### Ditambahkan
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://img.shields.io/badge/lisensi-ISC-ADFF2F" alt="Lisensi: ISC">
|
<img src="https://img.shields.io/badge/lisensi-ISC-ADFF2F" alt="Lisensi: ISC">
|
||||||
<img src="https://img.shields.io/badge/versi-0.5.11_gowa--test-ADFF2F" alt="Versi 0.5.11 (gowa-test)">
|
<img src="https://img.shields.io/badge/versi-0.5.12_gowa--test2-ADFF2F" alt="Versi 0.5.12 (gowa-test-unsaved)">
|
||||||
<img src="https://img.shields.io/badge/Node.js-%E2%89%A520-339933" alt="Node.js >= 20">
|
<img src="https://img.shields.io/badge/Node.js-%E2%89%A520-339933" alt="Node.js >= 20">
|
||||||
<img src="https://img.shields.io/badge/docker-ready-2496ED?logo=docker&logoColor=white" alt="Docker">
|
<img src="https://img.shields.io/badge/docker-ready-2496ED?logo=docker&logoColor=white" alt="Docker">
|
||||||
<a href="https://demo-openisp.oxpoe.xyz"><img src="https://img.shields.io/badge/demo-live-ADFF2F?logo=googlechrome&logoColor=black" alt="Demo"></a>
|
<a href="https://demo-openisp.oxpoe.xyz"><img src="https://img.shields.io/badge/demo-live-ADFF2F?logo=googlechrome&logoColor=black" alt="Demo"></a>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "open-isp",
|
"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)",
|
"description": "OPEN-ISP \u2014 sistem billing & manajemen ISP open-source (PWA pelanggan, multi-OLT, RADIUS, WhatsApp, QRIS)",
|
||||||
"main": "app-customer.js",
|
"main": "app-customer.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -6770,10 +6770,15 @@ router.post('/whatsapp/gateway-settings', requireAdminSession, express.urlencode
|
|||||||
res.redirect('/admin/whatsapp');
|
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 {
|
try {
|
||||||
const gowaSvc = require('../services/gowaWhatsappService');
|
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));
|
return res.json(Object.assign({ ok: r.reachable, success: r.reachable }, r));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.status(500).json({ ok: false, success: false, message: e.message });
|
return res.status(500).json({ ok: false, success: false, message: e.message });
|
||||||
|
|||||||
@@ -131,8 +131,15 @@ async function sendGowaDocument(toPhone, documentBuffer, filename = 'file.pdf',
|
|||||||
});
|
});
|
||||||
return { success: true, gateway: 'gowa', raw: json };
|
return { success: true, gateway: 'gowa', raw: json };
|
||||||
}
|
}
|
||||||
async function testReachability() {
|
async function testReachability(opts = {}) {
|
||||||
const base = baseUrl();
|
// 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: '' };
|
const out = { baseUrl: base, reachable: false, healthStatus: 0, authOk: false, devices: 0, message: '' };
|
||||||
try {
|
try {
|
||||||
const res = await fetch(base + '/health');
|
const res = await fetch(base + '/health');
|
||||||
@@ -147,7 +154,7 @@ async function testReachability() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const res = await fetch(base + '/devices', { headers: commonHeaders() });
|
const res = await fetch(base + '/devices', { headers: headers });
|
||||||
out.authStatus = res.status;
|
out.authStatus = res.status;
|
||||||
const json = await res.json().catch(function () { return null; });
|
const json = await res.json().catch(function () { return null; });
|
||||||
const list = (json && Array.isArray(json.results)) ? json.results : [];
|
const list = (json && Array.isArray(json.results)) ? json.results : [];
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0.5.11
|
0.5.12
|
||||||
@@ -245,7 +245,16 @@
|
|||||||
if (btn) { btn.disabled = true; btn.innerHTML = '<i class="bi bi-hourglass-split"></i> Menguji...'; }
|
if (btn) { btn.disabled = true; btn.innerHTML = '<i class="bi bi-hourglass-split"></i> Menguji...'; }
|
||||||
if (el) { el.style.display = 'block'; el.style.color = 'var(--muted)'; el.textContent = 'Menghubungi ' + (document.querySelector('input[name="gowa_base_url"]') || {}).value + ' ...'; }
|
if (el) { el.style.display = 'block'; el.style.color = 'var(--muted)'; el.textContent = 'Menghubungi ' + (document.querySelector('input[name="gowa_base_url"]') || {}).value + ' ...'; }
|
||||||
try {
|
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();
|
var d = await r.json();
|
||||||
if (el) {
|
if (el) {
|
||||||
el.textContent = d.message || (d.ok ? 'GOWA terjangkau.' : 'GOWA tidak terjangkau.');
|
el.textContent = d.message || (d.ok ? 'GOWA terjangkau.' : 'GOWA tidak terjangkau.');
|
||||||
|
|||||||
Reference in New Issue
Block a user