fix: verificare, ma dovrebbe essere corretta la lattura da ldap

This commit is contained in:
2026-07-08 00:58:52 +02:00
parent bf8b4c387e
commit 78a26fe970
7 changed files with 231 additions and 34 deletions
+13 -1
View File
@@ -459,6 +459,18 @@ router.post('/', async (req, res) => {
const c = custRes.rows[0];
customerFrom = `${c.first_name} ${c.last_name} <${c.email}>`;
senderTypeName = 'customer';
} else if (process.env.OTRS_API_URL && process.env.OTRS_API_USER) {
try {
const getResult = await otrsRequest('POST', '/CustomerUserGet', { UserLogin: customer_user_id });
const getData = (getResult && getResult.Data) || getResult;
if (getData && getData.CustomerUser) {
const u = getData.CustomerUser;
customerFrom = `${u.UserFirstname || ''} ${u.UserLastname || ''} <${u.UserEmail || ''}>`.trim();
senderTypeName = 'customer';
}
} catch (apiErr) {
console.warn(`Failed to fetch LDAP customer details for ${customer_user_id}:`, apiErr.message);
}
}
}
@@ -1351,7 +1363,7 @@ router.get('/attachments/:id', async (req, res) => {
} else if (typeof attachment.content === 'string') {
contentStr = attachment.content;
}
const cleaned = contentStr.replace(/\s+/g, '');
const base64Regex = /^[A-Za-z0-9+/]*={0,2}$/;
if (cleaned.length % 4 === 0 && base64Regex.test(cleaned)) {