feat: show finding IDs in history, display Ivanti reviewer notes (rework/approval feedback) in history tab
This commit is contained in:
@@ -560,6 +560,43 @@ function createIvantiFpWorkflowRouter(db, requireAuth) {
|
||||
for (const sub of submissions) {
|
||||
sub.history = historyMap[sub.id] || [];
|
||||
}
|
||||
|
||||
// Enrich submissions with Ivanti reviewer notes (rework/approval feedback)
|
||||
const apiKey = process.env.IVANTI_API_KEY;
|
||||
const clientId = process.env.IVANTI_CLIENT_ID || '1550';
|
||||
const skipTls = process.env.IVANTI_SKIP_TLS === 'true';
|
||||
|
||||
if (apiKey) {
|
||||
try {
|
||||
// Batch search by all workflow names
|
||||
for (const sub of submissions) {
|
||||
if (!sub.workflow_name) continue;
|
||||
const searchUrl = `/client/${encodeURIComponent(clientId)}/workflowBatch/search`;
|
||||
const searchBody = {
|
||||
filters: [{ field: 'name', exclusive: false, operator: 'EXACT', value: sub.workflow_name }],
|
||||
projection: 'internal',
|
||||
sort: [{ field: 'created', direction: 'DESC' }],
|
||||
page: 0, size: 1
|
||||
};
|
||||
const result = await ivantiPost(searchUrl, searchBody, apiKey, skipTls);
|
||||
if (result.status === 200) {
|
||||
const data = JSON.parse(result.body);
|
||||
const batches = data._embedded?.workflowBatches || data._embedded?.workflowBatch || [];
|
||||
const batch = batches[0];
|
||||
if (batch) {
|
||||
sub.ivanti_rework_note = batch.reworkNote || null;
|
||||
sub.ivanti_approval_note = batch.approvalNote || null;
|
||||
sub.ivanti_current_state_notes = batch.currentStateUserNotes || null;
|
||||
sub.ivanti_previous_state_notes = batch.previousStateUserNotes || null;
|
||||
sub.ivanti_current_state = batch.currentState || null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error enriching submissions with Ivanti notes:', e.message);
|
||||
// Don't fail the response — notes are supplementary
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No submissions, nothing to do
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user