Skip to content

Commit

Permalink
fix typo in action name, and use consistent format for logger (#3787)
Browse files Browse the repository at this point in the history
Co-authored-by: mansaj <[email protected]>
  • Loading branch information
rhelmer and mansaj authored Nov 22, 2023
1 parent 6eb48db commit c9d0791
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/app/api/v1/admin/users/[primarySha1]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,21 @@ export async function PUT(
// Signed in as admin
try {
const primarySha1 = params.primarySha1;
if (!params.primarySha1) {
if (!primarySha1) {
return NextResponse.json({ success: false }, { status: 400 });
}

const body = await req.json();
const actions = body.actions;

if (!primarySha1) {
return NextResponse.json({ success: false }, { status: 400 });
}

const subscriber = (await getSubscribersByHashes([primarySha1]))[0];
const result = await getOnerepProfileId(subscriber.id);
const onerepProfileId = result?.[0]?.["onerep_profile_id"] as number;

logger.debug("admin_subscription_change", JSON.stringify(result));
logger.info("admin_subscription_change", {
actions,
subscriberId: subscriber.id,
});

for (const action of actions) {
switch (action) {
Expand Down Expand Up @@ -150,7 +149,7 @@ export async function PUT(
});
break;
}
case "delete_onrep_scan_results": {
case "delete_onerep_scan_results": {
await deleteScanResultsForProfile(onerepProfileId);
logger.info("delete_onerep_scan_results", {
onerepProfileId,
Expand All @@ -167,7 +166,7 @@ export async function PUT(
break;
}
default: {
logger.error("Unknown action:", action);
logger.error("unknown_action", action);
return NextResponse.json({ success: false }, { status: 500 });
}
}
Expand Down

0 comments on commit c9d0791

Please sign in to comment.