Skip to content

Commit

Permalink
[SIEM][CASE] Create comments sequentially (#63692)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Apr 16, 2020
1 parent dde3d96 commit 10ccc0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/case/server/routes/api/cases/get_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 10ccc0a

Please sign in to comment.