diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 19becf7..9e834d2 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,16 @@
-
-
+
+
+
+
+
+
+
+
+
@@ -47,9 +54,9 @@
@@ -134,6 +141,11 @@
]
}
}
+
+
+
+
+
@@ -231,6 +243,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -271,8 +331,8 @@
-
-
+
+
@@ -309,7 +369,9 @@
-
+
+
+
@@ -359,7 +421,79 @@
1714332311321
-
+
+
+ 1722804244115
+
+
+
+ 1722804244115
+
+
+
+ 1722804255328
+
+
+
+ 1722804255328
+
+
+
+ 1722804722354
+
+
+
+ 1722804722354
+
+
+
+ 1722804816532
+
+
+
+ 1722804816532
+
+
+
+ 1722804890007
+
+
+
+ 1722804890007
+
+
+
+ 1722810187257
+
+
+
+ 1722810187257
+
+
+
+ 1722811549943
+
+
+
+ 1722811549943
+
+
+
+ 1722812594171
+
+
+
+ 1722812594171
+
+
+
+ 1722812932077
+
+
+
+ 1722812932077
+
+
@@ -384,6 +518,15 @@
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/alttd/forms/apply/StaffAppController.java b/src/main/java/com/alttd/forms/apply/StaffAppController.java
new file mode 100644
index 0000000..8451ef1
--- /dev/null
+++ b/src/main/java/com/alttd/forms/apply/StaffAppController.java
@@ -0,0 +1,42 @@
+package com.alttd.forms.apply;
+
+import com.alttd.forms.form.StoreFormQuery;
+import com.alttd.forms.mail.verification.VerificationResult;
+import com.alttd.forms.mail.verification.Verify;
+import jakarta.validation.Valid;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.concurrent.CompletableFuture;
+
+public class StaffAppController {
+
+
+ private static final Logger logger = LoggerFactory.getLogger(StaffAppController.class);
+
+ @PostMapping("/staffApplication")
+ public CompletableFuture> submitForm(@Valid @RequestBody StaffAppFormData formData) {
+ logger.debug("submitForm");
+ logger.trace(formData.toString());
+
+ CompletableFuture storeFormForVerificationCode = new StoreFormQuery().storeFormForVerificationCode(formData.email, formData);
+ return storeFormForVerificationCode.thenCompose(code -> Verify.verifyEmail(formData.email, code).thenApply(verificationResult -> {
+ if (verificationResult == VerificationResult.VERIFICATION_SENT) {
+ //TODO if this is ok tell the user they have x min to verify if they fail to do so they have to remake the form
+ logger.trace("Staff application form stored and requested verification from user");
+ return ResponseEntity.ok("User Data received and email verification sent.");
+ } else {
+ logger.trace("Failed to send verification email");
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body("Failed to send verification email. Reason: " + verificationResult.name());
+ }
+ })).exceptionally(throwable -> {
+ logger.error("Failed to store form", throwable);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to store your form");
+ });
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/alttd/forms/apply/StaffAppFormData.java b/src/main/java/com/alttd/forms/apply/StaffAppFormData.java
new file mode 100644
index 0000000..470f47f
--- /dev/null
+++ b/src/main/java/com/alttd/forms/apply/StaffAppFormData.java
@@ -0,0 +1,118 @@
+package com.alttd.forms.apply;
+
+import com.alttd.forms.form.Form;
+import jakarta.validation.constraints.*;
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.Range;
+
+import java.time.LocalDate;
+
+public class StaffAppFormData extends Form {
+
+ public StaffAppFormData(String username, String email, String discord, String pc_requirements, int age, String pronoun, LocalDate join_date, int avg_time, String available_days, String available_time, String staff_experience, String plugin_experience, String why_staff, String expectations_mod, String other) {
+ this.username = username;
+ this.email = email;
+ this.discord = discord;
+ this.pc_requirements = pc_requirements;
+ this.age = age;
+ this.pronoun = pronoun;
+ this.join_date = join_date;
+ this.avg_time = avg_time;
+ this.available_days = available_days;
+ this.available_time = available_time;
+ this.staff_experience = staff_experience;
+ this.plugin_experience = plugin_experience;
+ this.why_staff = why_staff;
+ this.expectations_mod = expectations_mod;
+ this.other = other;
+ }
+
+ @NotEmpty(message = "Username is required")
+ @Length(min = 3, max = 16, message = "Username should be between 3 and 16 characters")
+ @Pattern(regexp = "^[a-zA-Z0-9_]*$", message = "Username should only include alphanumeric characters and underscore")
+ public final String username;
+
+ @NotEmpty(message = "E-mail address is required")
+ @Email(message = "Invalid email")
+ @Length(min = 3, max = 254, message = "Email should be between 3 and 254 characters")
+ public final String email;
+
+ @NotEmpty(message = "Discord name is required")
+ @Length(min = 2, max = 32, message = "Discord name should be between 2 and 32 characters")
+ @Pattern(regexp = "^(?!.*\\..)([a-z0-9._]{2,32})$", message = "Please enter a valid Discord name")
+ public final String discord;
+
+ @NotEmpty(message = "An answer is required")
+ @Length(min = 2, max = 3, message = "Please answer 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")
+ @Max(value = 999, message = "We do not accept players older than 999 years old sorry!")
+ public final int age;
+
+ @Length(max = 16, message = "Pronouns can't be longer than 16 characters")
+ public final String pronoun;
+
+ @NotNull(message = "Your join date is required, if you're not sure enter an estimated date")
+ public final LocalDate join_date;
+
+ @Range(min = 0, max = 168, message = "The only valid values are 0-168")
+ public final int avg_time;
+
+ @NotEmpty(message = "Available days are required")
+ @Length(min = 6, max = 128, message = "Available days should be between 6 and 128 characters")
+ public final String available_days;
+
+ @NotEmpty(message = "Available time is required")
+ @Length(min = 3, max = 256, message = "Available time should be between 3 and 256 characters")
+ public final String available_time;
+
+ @NotEmpty(message = "Staff experience is required")
+ @Length(min = 2, max = 2000, message = "Experience should be between 2 and 2000 characters")
+ public final String staff_experience;
+
+ @NotEmpty(message = "Plugin experience is required")
+ @Length(min = 2, max = 2000, message = "Experience should be between 2 and 2000 characters")
+ public final String plugin_experience;
+
+ @NotEmpty(message = "Reason for wanting to be a moderator is required")
+ @Length(min = 2, max =2000, message = "Reason should be between 2 and 2000 characters")
+ public final String why_staff;
+
+ @NotEmpty(message = "Expectations of a moderator is required")
+ @Length(min = 2, max = 2000, message = "Expectation should be between 2 and 2000 characters")
+ public final String expectations_mod;
+
+ @Length(max = 2000, message = "Text can't be longer than 2000 characters")
+ public final String other;
+
+ @Override
+ public String toString() {
+ return "StaffAppFormData{" +
+ "username='" + username + '\'' +
+ ", email='" + email + '\'' +
+ ", discord='" + discord + '\'' +
+ ", pc_requirements='" + pc_requirements + '\'' +
+ ", age=" + age +
+ ", pronoun='" + pronoun + '\'' +
+ ", join_date=" + join_date +
+ ", avg_time=" + avg_time +
+ ", available_days='" + available_days + '\'' +
+ ", available_time='" + available_time + '\'' +
+ ", staff_experience='" + staff_experience + '\'' +
+ ", plugin_experience='" + plugin_experience + '\'' +
+ ", why_staff='" + why_staff + '\'' +
+ ", expectations_mod='" + expectations_mod + '\'' +
+ ", other='" + other + '\'' +
+ '}';
+ }
+
+ @Override
+ public String toHtml() {
+ String[] fields = {"Username", "Email", "Discord", "PC requirements", "Age", "Pronoun", "Join date", "Avg time", "Available days", "Available time", "Staff experience", "Plugin experience", "Why staff", "Expectations mod", "Other"};
+ String[] values = {username, email, discord, pc_requirements, String.valueOf(age), pronoun, join_date.toString(), String.valueOf(avg_time), available_days, available_time, staff_experience, plugin_experience, why_staff, expectations_mod, other};
+
+ return toHtml(fields, values);
+ }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index a207671..052fd6d 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,2 +1,3 @@
logging.level.com.alttd.forms=warn
-server.port=8002
\ No newline at end of file
+server.port=8002
+spring.jackson.date-format=yyyy-MM-dd
\ No newline at end of file