-
Notifications
You must be signed in to change notification settings - Fork 16
Send out web socket event when malware scanner finishes #435
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
base: main
Are you sure you want to change the base?
Changes from all commits
5a7bddb
bc1ad45
ef8098a
60837e7
0cb62fb
f10a029
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,6 +199,34 @@ class MalwareScanner extends cds.ApplicationService { | |
| UPDATE.entity(target).where(where).set(updateObject), | ||
| UPDATE.entity(target.drafts).where(where).set(updateObject), | ||
| ]) | ||
| const broadcastUpdate = cds.spawn({}, async () => { | ||
| const [active, draft] = await Promise.all([ | ||
| SELECT.one.from(target).where(where), | ||
| SELECT.one.from(target.drafts).where(where), | ||
| ]) | ||
|
Comment on lines
+203
to
+206
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Consider querying by the original plain keys object (passed as a separate parameter, or stored before the compound expression is built) rather than the raw Please provide feedback on the review comment by checking the appropriate box:
|
||
| const parentEntity = target.elements.up_?._target | ||
| if (parentEntity?._service) { | ||
| const srv = await cds.connect.to(parentEntity._service.name) | ||
| const parentEntityName = parentEntity.name.split(".").pop() | ||
| const result = draft ?? active | ||
| if (result) { | ||
| const isActiveEntity = !draft | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic Error:
Please provide feedback on the review comment by checking the appropriate box:
|
||
| const parentKeys = Object.keys(result) | ||
| .filter((k) => k.startsWith("up__")) | ||
| .map((k) => `${k.slice(4)}=${result[k]}`) | ||
| .join(",") | ||
| srv.emit("attachmentStatusChanged", { | ||
| sideEffectSource: `/${parentEntityName}(${parentKeys},IsActiveEntity=${isActiveEntity})`, | ||
| }) | ||
| } | ||
| } | ||
| }) | ||
| broadcastUpdate.on("failed", (error) => { | ||
| LOG.debug( | ||
| `Emitting websocket event attachmentStatusChanged failed with: `, | ||
| error, | ||
| ) | ||
| }) | ||
| } else { | ||
| await UPDATE.entity(target).where(where).set(updateObject) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.