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/).
|
||||
|
||||
## [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
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<p align="center">
|
||||
<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/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>
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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 : [];
|
||||
|
||||
@@ -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 (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.');
|
||||
|
||||
Reference in New Issue
Block a user