Skip to content

Commit 10ccc0a

Browse files
authored
[SIEM][CASE] Create comments sequentially (#63692)
1 parent dde3d96 commit 10ccc0a

File tree

2 files changed

+12
-1
lines changed
  • x-pack/plugins
    • actions/server/builtin_action_types/servicenow/lib
    • case/server/routes/api/cases

2 files changed

+12
-1
lines changed

x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,14 @@ class ServiceNow {
147147
comments: Comment[],
148148
field: string
149149
): Promise<CommentResponse[]> {
150-
const res = await Promise.all(comments.map(c => this.createComment(incidentId, c, field)));
150+
// Create comments sequentially.
151+
const promises = comments.reduce(async (prevPromise, currentComment) => {
152+
const totalComments = await prevPromise;
153+
const res = await this.createComment(incidentId, currentComment, field);
154+
return [...totalComments, res];
155+
}, Promise.resolve([] as CommentResponse[]));
156+
157+
const res = await promises;
151158
return res;
152159
}
153160

x-pack/plugins/case/server/routes/api/cases/get_case.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export function initGetCaseApi({ caseService, router }: RouteDeps) {
4040
const theComments = await caseService.getAllCaseComments({
4141
client,
4242
caseId: request.params.case_id,
43+
options: {
44+
sortField: 'created_at',
45+
sortOrder: 'asc',
46+
},
4347
});
4448

4549
return response.ok({

0 commit comments

Comments
 (0)