[SIEM][CASE] Create comments sequentially (#63692)
This commit is contained in:
parent
dde3d96b14
commit
10ccc0a2f2
|
@ -147,7 +147,14 @@ class ServiceNow {
|
|||
comments: Comment[],
|
||||
field: string
|
||||
): Promise<CommentResponse[]> {
|
||||
const res = await Promise.all(comments.map(c => this.createComment(incidentId, c, field)));
|
||||
// Create comments sequentially.
|
||||
const promises = comments.reduce(async (prevPromise, currentComment) => {
|
||||
const totalComments = await prevPromise;
|
||||
const res = await this.createComment(incidentId, currentComment, field);
|
||||
return [...totalComments, res];
|
||||
}, Promise.resolve([] as CommentResponse[]));
|
||||
|
||||
const res = await promises;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@ export function initGetCaseApi({ caseService, router }: RouteDeps) {
|
|||
const theComments = await caseService.getAllCaseComments({
|
||||
client,
|
||||
caseId: request.params.case_id,
|
||||
options: {
|
||||
sortField: 'created_at',
|
||||
sortOrder: 'asc',
|
||||
},
|
||||
});
|
||||
|
||||
return response.ok({
|
||||
|
|
Loading…
Reference in a new issue