Improve admin visitor context layout

This commit is contained in:
rajchales-monito
2026-07-23 23:15:52 +02:00
parent 273056284c
commit 571770b1c3
4 changed files with 197 additions and 15 deletions
+18 -1
View File
@@ -570,7 +570,7 @@ function formatConversationSummary(row) {
language: row.language,
timezone: row.timezone,
ip: row.ip,
countryCode: row.country_code,
countryCode: row.country_code || countryFromTimezone(row.timezone) || countryFromLanguage(row.language),
vpnRisk: Boolean(row.vpn_risk),
lastBody: row.last_body,
messageCount: row.message_count,
@@ -750,6 +750,23 @@ function countryFromHeaders(req) {
return req.headers["cf-ipcountry"] || req.headers["x-vercel-ip-country"] || null;
}
function countryFromTimezone(timezone) {
const zones = {
"Europe/Prague": "CZ",
"Europe/Bratislava": "SK",
"Europe/Warsaw": "PL",
"Europe/Berlin": "DE",
"Europe/Vienna": "AT",
"Europe/Budapest": "HU"
};
return zones[String(timezone || "")] || null;
}
function countryFromLanguage(language) {
const match = String(language || "").match(/-([A-Za-z]{2})\b/);
return match ? match[1].toUpperCase() : null;
}
function isAllowedImageAttachment(attachment, buffer) {
const extension = path.extname(attachment.name || "").toLowerCase();
const type = String(attachment.type || "").toLowerCase();