Improve admin visitor context layout
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user