Skip to content

Commit 360f47b

Browse files
committed
Changes from Claude review
1 parent 0725f83 commit 360f47b

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

builder-api/src/main/java/org/acme/api/error/JsonServerExceptionMappers.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ public Response map(JsonParseException e) {
2929
Log.warn(e);
3030
// malformed JSON like { "schema": }
3131
return Response.status(Response.Status.BAD_REQUEST)
32-
.type(MediaType.APPLICATION_JSON)
33-
.entity(ApiError.of("JsonParseException: Malformed JSON.")).build();
32+
.type(MediaType.APPLICATION_JSON).entity(ApiError.of("Malformed JSON."))
33+
.build();
3434
}
3535

3636
@ServerExceptionMapper
3737
public Response map(WebApplicationException e) {
38-
Log.info("Some malformed JSON");
3938
Log.warn(e);
4039
return Response.status(Response.Status.BAD_REQUEST)
41-
.type(MediaType.APPLICATION_JSON)
42-
.entity(ApiError.of("WebApplicationException: Malformed JSON."))
40+
.type(MediaType.APPLICATION_JSON).entity(ApiError.of("Malformed JSON."))
4341
.build();
4442
}
4543

builder-api/src/main/java/org/acme/controller/AccountResource.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.quarkus.security.identity.SecurityIdentity;
44
import jakarta.inject.Inject;
5-
import jakarta.validation.Validator;
65
import jakarta.ws.rs.*;
76
import jakarta.ws.rs.core.*;
87

@@ -21,14 +20,12 @@
2120
@Path("/api")
2221
public class AccountResource {
2322

24-
@Inject
25-
Validator validator;
26-
2723
@Inject
2824
AccountHooks accountHooks;
2925

3026
@POST
3127
@Consumes(MediaType.APPLICATION_JSON)
28+
@Produces(MediaType.APPLICATION_JSON)
3229
@Path("/account-hooks")
3330
public Response accountHooks(@Context SecurityIdentity identity,
3431
AccountHookRequest request) {
@@ -51,13 +48,16 @@ public Response accountHooks(@Context SecurityIdentity identity,
5148

5249
// Run each action's function and determine whether successful
5350
Map<String, Boolean> hookResults = hooks.stream()
54-
.collect(Collectors.toMap(s -> s.toString(), s -> {
51+
.collect(Collectors.toMap(s -> s.getLabel(), s -> {
5552
Predicate<String> fn = hooksMap.get(s);
5653
return fn.test(userId);
5754
}));
5855

59-
AccountHookResponse responseBody = new AccountHookResponse(true,
60-
hookResults);
56+
Boolean allHooksSuccess = hookResults.values().stream()
57+
.allMatch(Boolean::booleanValue);
58+
59+
AccountHookResponse responseBody = new AccountHookResponse(
60+
allHooksSuccess, hookResults);
6161

6262
return Response.ok(responseBody).build();
6363
}

builder-api/src/main/java/org/acme/enums/AccountHookAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ public static AccountHookAction fromValue(String value) {
2727
}
2828
return UNABLE_TO_DETERMINE;
2929
}
30-
}
30+
}

builder-api/src/main/java/org/acme/model/dto/Auth/AccountHookRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
import org.acme.enums.AccountHookAction;
66

77
public record AccountHookRequest(Set<AccountHookAction> hooks) {
8-
}
8+
}

builder-api/src/main/java/org/acme/service/ExampleScreenerImportService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ private String upsertPublishedCustomCheck(
207207
try {
208208
eligibilityCheckRepository.saveNewPublishedCustomCheck(importedCheck);
209209
} catch (Exception e) {
210+
Log.info(e);
210211
eligibilityCheckRepository.updatePublishedCustomCheck(importedCheck);
211212
}
212213
}

builder-frontend/src/api/account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { authPost } from "@/api/auth";
44

55
const apiUrl = env.apiUrl;
66

7-
export const getAccountHooks = async () => {
7+
export const runAccountHooks = async () => {
88
const accountHookUrl = new URL(`${apiUrl}/account-hooks`);
99

1010
const hooksToCall = ["add example screener"];

builder-frontend/src/context/AuthContext.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import {
1212
createUserWithEmailAndPassword,
1313
signInWithPopup,
1414
GoogleAuthProvider,
15+
getAdditionalUserInfo,
1516
} from "firebase/auth";
1617

1718
import { auth } from "../firebase/firebase";
18-
import { getAccountHooks } from "@/api/account";
19+
import { runAccountHooks } from "@/api/account";
1920

2021
const AuthContext = createContext();
2122
const googleProvider = new GoogleAuthProvider();
@@ -46,7 +47,7 @@ export function AuthProvider(props) {
4647
setIsProvisioningAccount(true);
4748
return createUserWithEmailAndPassword(auth, email, password).then(
4849
(userCredential) => {
49-
getAccountHooks()
50+
return runAccountHooks()
5051
.then(
5152
() => {
5253
console.log("Successfully hooked the account.");
@@ -65,10 +66,11 @@ export function AuthProvider(props) {
6566
const loginWithGoogle = async () => {
6667
try {
6768
return signInWithPopup(auth, googleProvider).then((userCredential) => {
68-
const { operationType } = userCredential;
69-
if (operationType === "link" || operationType === "reauthenticate") {
69+
const isSignUp =
70+
getAdditionalUserInfo(userCredential)?.isNewUser || false;
71+
if (isSignUp) {
7072
setIsProvisioningAccount(true);
71-
getAccountHooks()
73+
runAccountHooks()
7274
.then(
7375
() => {
7476
console.log("Successfully hooked the account.");

0 commit comments

Comments
 (0)