Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM][CASE] Create comments sequentially #63692

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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