Compare commits

..

No commits in common. "9e0a33e7825638bca008bf48beb65ba168c1f86f" and "caabe7b923f038c708114451b7f2690b6696ac71" have entirely different histories.

8 changed files with 16 additions and 70 deletions

View File

@ -4,7 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="ce59df2a-8d56-446a-867b-80e627daf479" name="Changes" comment="Refactor form submission to use dynamic Discord URLs and emails&#10;&#10;Updated form classes to return Optional URLs for Discord bot submissions. Refactored VerifyController to handle these Optionals and improved error handling when sending forms. Added receiver email method in form classes for more flexible form submissions.">
<list default="true" id="ce59df2a-8d56-446a-867b-80e627daf479" name="Changes" comment="Add getDiscordBotUrl method to form classes&#10;&#10;Implemented getDiscordBotUrl in form classes for dynamic URL handling. Updated VerifyController to use this method for constructing Discord bot URIs. This enhances flexibility and maintainability in form submission handling.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -323,8 +323,8 @@
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-jdk-9823dce3aa75-b114ca120d71-intellij.indexing.shared.core-IU-242.20224.300" />
<option value="bundled-js-predefined-d6986cc7102b-410509235cf1-JavaScript-IU-242.20224.300" />
<option value="bundled-jdk-9f38398b9061-39b83d9b5494-intellij.indexing.shared.core-IU-241.18968.26" />
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-IU-241.18968.26" />
</set>
</attachedChunks>
</component>
@ -364,7 +364,6 @@
<workItem from="1722801254695" duration="6135000" />
<workItem from="1722879625782" duration="358000" />
<workItem from="1722973564053" duration="6695000" />
<workItem from="1723057624940" duration="36000" />
</task>
<task id="LOCAL-00001" summary="Initial commit for site for forms">
<option name="closed" value="true" />
@ -550,15 +549,7 @@
<option name="project" value="LOCAL" />
<updated>1722981675331</updated>
</task>
<task id="LOCAL-00024" summary="Refactor form submission to use dynamic Discord URLs and emails&#10;&#10;Updated form classes to return Optional URLs for Discord bot submissions. Refactored VerifyController to handle these Optionals and improved error handling when sending forms. Added receiver email method in form classes for more flexible form submissions.">
<option name="closed" value="true" />
<created>1722983786557</created>
<option name="number" value="00024" />
<option name="presentableId" value="LOCAL-00024" />
<option name="project" value="LOCAL" />
<updated>1722983786557</updated>
</task>
<option name="localTasksCounter" value="25" />
<option name="localTasksCounter" value="24" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -600,7 +591,6 @@
<MESSAGE value="Add REST annotations and refactor properties file handling&#10;&#10;Introduced `@RestController` and `@RequestMapping` in `StaffAppController` for standardized API endpoints. Refactored properties file handling in `PropertiesLoader` and `PropertiesWriter` to simplify file creation logic." />
<MESSAGE value="Update Jackson config and refactor JSON handling&#10;&#10;Introduced Jackson dependencies to replace Gson for JSON processing. Updated application properties and controllers to handle Jackson-specific exceptions. Refactored form serialization to use Jackson's `ObjectMapper` for better date handling and consistency." />
<MESSAGE value="Add getDiscordBotUrl method to form classes&#10;&#10;Implemented getDiscordBotUrl in form classes for dynamic URL handling. Updated VerifyController to use this method for constructing Discord bot URIs. This enhances flexibility and maintainability in form submission handling." />
<MESSAGE value="Refactor form submission to use dynamic Discord URLs and emails&#10;&#10;Updated form classes to return Optional URLs for Discord bot submissions. Refactored VerifyController to handle these Optionals and improved error handling when sending forms. Added receiver email method in form classes for more flexible form submissions." />
<option name="LAST_COMMIT_MESSAGE" value="Refactor form submission to use dynamic Discord URLs and emails&#10;&#10;Updated form classes to return Optional URLs for Discord bot submissions. Refactored VerifyController to handle these Optionals and improved error handling when sending forms. Added receiver email method in form classes for more flexible form submissions." />
<option name="LAST_COMMIT_MESSAGE" value="Add getDiscordBotUrl method to form classes&#10;&#10;Implemented getDiscordBotUrl in form classes for dynamic URL handling. Updated VerifyController to use this method for constructing Discord bot URIs. This enhances flexibility and maintainability in form submission handling." />
</component>
</project>

View File

@ -1,4 +1,4 @@
package com.alttd.forms.controlers.apply;
package com.alttd.forms.apply;
import com.alttd.forms.form.StoreFormQuery;
import com.alttd.forms.mail.verification.VerificationResult;
@ -8,7 +8,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.CompletableFuture;

View File

@ -1,4 +1,4 @@
package com.alttd.forms.controlers.apply;
package com.alttd.forms.apply;
import com.alttd.forms.form.Form;
import jakarta.validation.constraints.*;
@ -45,7 +45,7 @@ public class StaffAppFormData extends Form {
@NotEmpty(message = "An answer is required")
@Length(min = 2, max = 3, message = "Please answer yes or no")
@Pattern(regexp = "(?i)^(yes|no)$", message = "Yes or no")
@Pattern(regexp = "(yes|no)$", message = "Yes or no")
public final String pc_requirements;
@Min(value = 0, message = "Please enter a valid age")

View File

@ -1,4 +1,4 @@
package com.alttd.forms.controlers.contact;
package com.alttd.forms.contact;
import com.alttd.forms.form.StoreFormQuery;
import com.alttd.forms.mail.verification.VerificationResult;
import com.alttd.forms.mail.verification.Verify;

View File

@ -1,4 +1,4 @@
package com.alttd.forms.controlers.contact;
package com.alttd.forms.contact;
import com.alttd.forms.form.Form;
import jakarta.validation.constraints.Email;

View File

@ -1,47 +0,0 @@
package com.alttd.forms.controlers;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import java.util.HashMap;
import java.util.Map;
@ControllerAdvice
public class ControllerExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(ControllerExceptionHandler.class);
public ControllerExceptionHandler() {
logger.info("ControllerExceptionHandler initialized"); // Ensure this gets logged
}
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<Map<String, String>> handleValidationExceptions(MethodArgumentNotValidException ex) {
logger.debug("invalid request", ex);
Map<String, String> errors = new HashMap<>();
ex.getBindingResult().getAllErrors().forEach((error) -> {
String fieldName = ((FieldError) error).getField();
String errorMessage = error.getDefaultMessage();
errors.put(fieldName, errorMessage);
});
if (logger.isDebugEnabled()) {
try {
String errorsAsString = new ObjectMapper().writeValueAsString(errors);
logger.debug("Invalid parameters\n{}", errorsAsString);
} catch (JsonProcessingException e) {
logger.warn("Failed to parse errors to json", e);
}
}
return ResponseEntity.badRequest().body(errors);
}
}

View File

@ -1,6 +1,6 @@
package com.alttd.forms.verify_mail;
import com.alttd.forms.controlers.contact.ContactFormData;
import com.alttd.forms.contact.ContactFormData;
import com.alttd.forms.database.DatabaseConnection;
import com.alttd.forms.form.Form;
import com.fasterxml.jackson.core.JsonProcessingException;

View File

@ -1,4 +1,4 @@
import com.alttd.forms.controlers.contact.ContactFormData;
import com.alttd.forms.contact.ContactFormData;
import com.alttd.forms.form.StoreFormQuery;
import com.alttd.forms.database.DatabaseConnection;
import com.alttd.forms.form.Form;