Skip to content

Commit

Permalink
[7.7] [SIEM][CASE] Create comments sequentially (#63692) (#63744)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas authored Apr 17, 2020
1 parent 3cdf259 commit dc44d25
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 dc44d25

Please sign in to comment.