feat: funzione per l'invio della posta elettronica da otrs-turbo. fix: corretta consuntivazione automatica. feat: aggiunto link apri in otrs anche nel numero del ticket in cima
This commit is contained in:
+7
-2
@@ -23,13 +23,18 @@ async function resolveAgentName(agentId) {
|
||||
async function resolveAgentFromHeader(agentId, client = pool) {
|
||||
try {
|
||||
const r = await client.query(
|
||||
`SELECT first_name, last_name, email, login FROM users WHERE id = $1`,
|
||||
`SELECT first_name, last_name, login FROM users WHERE id = $1`,
|
||||
[agentId]
|
||||
);
|
||||
if (r.rows.length > 0) {
|
||||
const u = r.rows[0];
|
||||
const fullName = [u.first_name, u.last_name].filter(Boolean).join(' ') || u.login || 'Agent';
|
||||
const email = u.email || 'agent@localhost';
|
||||
|
||||
const prefRes = await client.query(
|
||||
`SELECT preferences_value FROM user_preferences WHERE user_id = $1 AND preferences_key = 'UserEmail'`,
|
||||
[agentId]
|
||||
);
|
||||
const email = (prefRes.rows.length > 0 && prefRes.rows[0].preferences_value) || 'agent@localhost';
|
||||
return `"${fullName}" <${email}>`;
|
||||
}
|
||||
} catch (_) { /* ignore */ }
|
||||
|
||||
Reference in New Issue
Block a user