v1.2.39 - Fix IP Bans page: convert rows+columns SQL response format to objects for display
This commit is contained in:
+19
-6
@@ -6220,7 +6220,20 @@ async function executeSqlQueryRaw(query, queryId) {
|
||||
|
||||
// Handle IP bans SQL response
|
||||
function handleIpBansResponse(responseData) {
|
||||
if (!responseData.results || responseData.results.length === 0) {
|
||||
// Convert rows+columns format to array of objects
|
||||
let results = [];
|
||||
if (responseData.rows && responseData.columns) {
|
||||
const cols = responseData.columns;
|
||||
results = responseData.rows.map(row => {
|
||||
const obj = {};
|
||||
cols.forEach((col, i) => { obj[col] = row[i]; });
|
||||
return obj;
|
||||
});
|
||||
} else if (responseData.results) {
|
||||
results = responseData.results;
|
||||
}
|
||||
|
||||
if (results.length === 0) {
|
||||
document.getElementById('ip-bans-tbody').innerHTML = '<tr><td colspan="7" style="text-align: center;">No IP bans found</td></tr>';
|
||||
document.getElementById('ip-bans-total').textContent = '0';
|
||||
document.getElementById('ip-bans-active').textContent = '0';
|
||||
@@ -6229,20 +6242,20 @@ function handleIpBansResponse(responseData) {
|
||||
}
|
||||
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
let totalIPs = responseData.results.length;
|
||||
let totalIPs = results.length;
|
||||
let currentlyBanned = 0;
|
||||
let totalBans = 0;
|
||||
|
||||
// Filter results based on current filter
|
||||
let filteredResults = responseData.results;
|
||||
let filteredResults = results;
|
||||
if (ipBansFilter === 'banned') {
|
||||
filteredResults = responseData.results.filter(row => row.banned_until > now);
|
||||
filteredResults = results.filter(row => row.banned_until > now);
|
||||
} else if (ipBansFilter === 'expired') {
|
||||
filteredResults = responseData.results.filter(row => row.banned_until <= now && row.banned_until > 0);
|
||||
filteredResults = results.filter(row => row.banned_until <= now && row.banned_until > 0);
|
||||
}
|
||||
|
||||
// Calculate stats
|
||||
responseData.results.forEach(row => {
|
||||
results.forEach(row => {
|
||||
totalBans += parseInt(row.ban_count || 0);
|
||||
if (row.banned_until > now) {
|
||||
currentlyBanned++;
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@
|
||||
// Using CRELAY_ prefix to avoid conflicts with nostr_core_lib VERSION macros
|
||||
#define CRELAY_VERSION_MAJOR 1
|
||||
#define CRELAY_VERSION_MINOR 2
|
||||
#define CRELAY_VERSION_PATCH 38
|
||||
#define CRELAY_VERSION "v1.2.38"
|
||||
#define CRELAY_VERSION_PATCH 39
|
||||
#define CRELAY_VERSION "v1.2.39"
|
||||
|
||||
// Relay metadata (authoritative source for NIP-11 information)
|
||||
#define RELAY_NAME "C-Relay"
|
||||
|
||||
Reference in New Issue
Block a user