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

Don't wait for csam call to complete #98

Open
wants to merge 4 commits into
base: stage
Choose a base branch
from
Open
Changes from 3 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
28 changes: 16 additions & 12 deletions unitylibs/core/workflow/workflow-photoshop/workflow-photoshop.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ function addOrUpdateOperation(array, keyToCheck, valueToCheck, keyToUpdate, newV
}
}

async function scanForCsam(cfg, id, unityEl, refreshWidgetEvent) {
const { scanImgForSafety } = await import('../../steps/upload-step.js');
let scanResponse = await scanImgForSafety(cfg, id);
if (scanResponse.status === 403) {
unityEl.dispatchEvent(new CustomEvent(refreshWidgetEvent));
//await showErrorToast(targetEl, unityEl, '.icon-error-acmp');
return false;
}
Ruchika4 marked this conversation as resolved.
Show resolved Hide resolved
if (scanResponse.status === 429
|| (scanResponse.status >= 500 && scanResponse.status < 600)) {
const { retryRequestUntilProductRedirect } = await import('../../../scripts/utils.js');
scanResponse = await retryRequestUntilProductRedirect(cfg, () => scanImgForSafety(cfg, id));
}
}

function resetWorkflowState(cfg) {
cfg.presentState = {
activeIdx: cfg.isUpload ? 0 : -1,
Expand Down Expand Up @@ -159,18 +174,7 @@ async function removeBgHandler(cfg, changeDisplay = true) {
return false;
}
if (isImgModified) {
const { scanImgForSafety } = await import('../../steps/upload-step.js');
let scanResponse = await scanImgForSafety(cfg, id);
if (scanResponse.status === 403) {
unityEl.dispatchEvent(new CustomEvent(refreshWidgetEvent));
await showErrorToast(targetEl, unityEl, '.icon-error-acmp');
return false;
}
if (scanResponse.status === 429
|| (scanResponse.status >= 500 && scanResponse.status < 600)) {
const { retryRequestUntilProductRedirect } = await import('../../../scripts/utils.js');
scanResponse = await retryRequestUntilProductRedirect(cfg, () => scanImgForSafety(cfg, id));
}
scanForCsam(cfg, id, unityEl, refreshWidgetEvent );
Ruchika4 marked this conversation as resolved.
Show resolved Hide resolved
}
cfg.preludeState.assetId = id;
const removeBgOptions = {
Expand Down