Feinheiten
This commit is contained in:
1 parent
801455dfcc
commit
0cd522acd8
2 files changed
+8
-4
No files matched your search
@@ -31,7 +31,7 @@ public class CodeController {
|
|||||||
private final RandomStringUtils randomStringUtils = RandomStringUtils.secure();
|
private final RandomStringUtils randomStringUtils = RandomStringUtils.secure();
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<GetSessionAndAllRiddleData> check(@RequestParam() String code) {
|
public ResponseEntity<GetSessionAndAllRiddleData> check(@RequestParam(required = true) String code) {
|
||||||
if (code == null || code.length() < 9) {
|
if (code == null || code.length() < 9) {
|
||||||
return ResponseEntity.notFound().build();
|
return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class CodeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResponseEntity<String> create(@RequestParam() String code) {
|
public ResponseEntity<String> create(@RequestParam(required = false) String code) {
|
||||||
TourCode t = null;
|
TourCode t = null;
|
||||||
if (code == null || code.length() < 9) {
|
if (code == null || code.length() < 9) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@@ -90,7 +90,7 @@ public class CodeController {
|
|||||||
if (t == null) {
|
if (t == null) {
|
||||||
t = tourCodeService.addTourCode(code);
|
t = tourCodeService.addTourCode(code);
|
||||||
System.out.println("DEBUG: Created TC " + t.getId());
|
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());
|
return ResponseEntity.badRequest().body("BAD: " + t.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,14 @@ public class SessionController {
|
|||||||
return ResponseEntity.badRequest().body("No Code");
|
return ResponseEntity.badRequest().body("No Code");
|
||||||
}
|
}
|
||||||
TourCode tourCode = tourCodeService.getTourCodeByCode(code);
|
TourCode tourCode = tourCodeService.getTourCodeByCode(code);
|
||||||
if (tourCode == null) {
|
if (tourCode == null || !tourCode.getActivated()) {
|
||||||
return ResponseEntity.notFound().build();
|
return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
LocalDateTime now = Utils.getDateTimeNow();
|
LocalDateTime now = Utils.getDateTimeNow();
|
||||||
|
LocalDateTime activationTimestamp = tourCode.getActivationTimestamp();
|
||||||
|
if (activationTimestamp.plus(12, ChronoUnit.HOURS).isBefore(now)) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
LocalDateTime heartbeat = tourCode.getLastHeartbeatTimestamp();
|
LocalDateTime heartbeat = tourCode.getLastHeartbeatTimestamp();
|
||||||
if (heartbeat != null && heartbeat.plus(3, ChronoUnit.MINUTES).isBefore(now)) {
|
if (heartbeat != null && heartbeat.plus(3, ChronoUnit.MINUTES).isBefore(now)) {
|
||||||
return ResponseEntity.badRequest().body("Code invalid");
|
return ResponseEntity.badRequest().body("Code invalid");
|
||||||
|
|||||||
Reference in new issue
Block a user