Compare commits

..
1 Commits
Author SHA1 Message Date
LionTion 0cd522acd8 Feinheiten 2026-10-18 22:05:49 +02:00
2 changed files with 8 additions and 4 deletions

No files matched your search

@@ -31,7 +31,7 @@ public class CodeController {
private final RandomStringUtils randomStringUtils = RandomStringUtils.secure();
@GetMapping
public ResponseEntity<GetSessionAndAllRiddleData> check(@RequestParam() String code) {
public ResponseEntity<GetSessionAndAllRiddleData> check(@RequestParam(required = true) String code) {
if (code == null || code.length() < 9) {
return ResponseEntity.notFound().build();
}
@@ -69,7 +69,7 @@ public class CodeController {
}
@PostMapping
public ResponseEntity<String> create(@RequestParam() String code) {
public ResponseEntity<String> create(@RequestParam(required = false) String code) {
TourCode t = null;
if (code == null || code.length() < 9) {
boolean found = false;
@@ -90,7 +90,7 @@ public class CodeController {
if (t == null) {
t = tourCodeService.addTourCode(code);
System.out.println("DEBUG: Created TC " + t.getId());
return ResponseEntity.ok(t.getId().toString());
return ResponseEntity.ok(t.getCode());
}
return ResponseEntity.badRequest().body("BAD: " + t.getId());
}
@@ -41,10 +41,14 @@ public class SessionController {
return ResponseEntity.badRequest().body("No Code");
}
TourCode tourCode = tourCodeService.getTourCodeByCode(code);
if (tourCode == null) {
if (tourCode == null || !tourCode.getActivated()) {
return ResponseEntity.notFound().build();
}
LocalDateTime now = Utils.getDateTimeNow();
LocalDateTime activationTimestamp = tourCode.getActivationTimestamp();
if (activationTimestamp.plus(12, ChronoUnit.HOURS).isBefore(now)) {
return ResponseEntity.notFound().build();
}
LocalDateTime heartbeat = tourCode.getLastHeartbeatTimestamp();
if (heartbeat != null && heartbeat.plus(3, ChronoUnit.MINUTES).isBefore(now)) {
return ResponseEntity.badRequest().body("Code invalid");