mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 09:47:40 +00:00
refactor(gateway): dedupe wizard and exec approval handler paths
This commit is contained in:
@@ -77,6 +77,15 @@ function redactExecApprovals(file: ExecApprovalsFile): ExecApprovalsFile {
|
||||
};
|
||||
}
|
||||
|
||||
function toExecApprovalsPayload(snapshot: ExecApprovalsSnapshot) {
|
||||
return {
|
||||
path: snapshot.path,
|
||||
exists: snapshot.exists,
|
||||
hash: snapshot.hash,
|
||||
file: redactExecApprovals(snapshot.file),
|
||||
};
|
||||
}
|
||||
|
||||
export const execApprovalsHandlers: GatewayRequestHandlers = {
|
||||
"exec.approvals.get": ({ params, respond }) => {
|
||||
if (!assertValidParams(params, validateExecApprovalsGetParams, "exec.approvals.get", respond)) {
|
||||
@@ -84,16 +93,7 @@ export const execApprovalsHandlers: GatewayRequestHandlers = {
|
||||
}
|
||||
ensureExecApprovals();
|
||||
const snapshot = readExecApprovalsSnapshot();
|
||||
respond(
|
||||
true,
|
||||
{
|
||||
path: snapshot.path,
|
||||
exists: snapshot.exists,
|
||||
hash: snapshot.hash,
|
||||
file: redactExecApprovals(snapshot.file),
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
respond(true, toExecApprovalsPayload(snapshot), undefined);
|
||||
},
|
||||
"exec.approvals.set": ({ params, respond }) => {
|
||||
if (!assertValidParams(params, validateExecApprovalsSetParams, "exec.approvals.set", respond)) {
|
||||
@@ -117,16 +117,7 @@ export const execApprovalsHandlers: GatewayRequestHandlers = {
|
||||
const next = mergeExecApprovalsSocketDefaults({ normalized, current: snapshot.file });
|
||||
saveExecApprovals(next);
|
||||
const nextSnapshot = readExecApprovalsSnapshot();
|
||||
respond(
|
||||
true,
|
||||
{
|
||||
path: nextSnapshot.path,
|
||||
exists: nextSnapshot.exists,
|
||||
hash: nextSnapshot.hash,
|
||||
file: redactExecApprovals(nextSnapshot.file),
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
respond(true, toExecApprovalsPayload(nextSnapshot), undefined);
|
||||
},
|
||||
"exec.approvals.node.get": async ({ params, respond, context }) => {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user