Skip to content

Commit b74508f

Browse files
authored
Merge branch 'main' into feature/lecture-interface-models
2 parents a5bddff + e334561 commit b74508f

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

.github/workflows/deploy-docker-image-on-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- "main"
7-
- "feature/bugfinder-backend"
8-
- "feature/lecture-interface-models"
97
tags:
108
- "v*"
119
pull_request:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 GamifyIT – A Web-based Gaming Platform for Computer Science Education in the First Semesters
3+
Copyright (c) 2022 Aaron Schmid, Florian Wüst, Gilian Rehm, Ilijaz Mehmedovic, Jonathan Scholz, Leon Hofmeister, Leon Layer, Levi Otterbach, Martin Lautenschlager, Max Kästner, Michael Linder & Timo Schnaible
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/main/java/de/unistuttgart/bugfinder/gameresult/GameResultController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public GameResultDTO saveGameResult(
2626
jwtValidatorService.validateTokenOrThrow(accessToken);
2727
final String userId = jwtValidatorService.extractUserId(accessToken);
2828
log.debug("save game result for userId {}: {}", userId, gameResultDTO);
29-
gameResultService.saveGameResult(gameResultDTO, userId);
29+
gameResultService.saveGameResult(gameResultDTO, userId, accessToken);
3030
return gameResultDTO;
3131
}
3232
}

src/main/java/de/unistuttgart/bugfinder/gameresult/GameResultService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,25 @@ public class GameResultService {
3636
@Autowired
3737
private ResultClient resultClient;
3838

39-
public void saveGameResult(final GameResultDTO gameResultDTO, final String userId) {
39+
/**
40+
* Casts a GameResultDTO to GameResult and submits to overworld backend.
41+
*
42+
* @param gameResultDTO extern gameResultDTO
43+
* @param userId id of the user
44+
* @param accessToken accessToken of the user
45+
* @throws IllegalArgumentException if at least one of the arguments is null
46+
*/
47+
public void saveGameResult(final GameResultDTO gameResultDTO, final String userId, final String accessToken) {
48+
if (gameResultDTO == null || userId == null || accessToken == null) {
49+
throw new IllegalArgumentException("At least one argument is null");
50+
}
4051
final OverworldResultDTO resultDTO = new OverworldResultDTO(
4152
gameResultDTO.getConfigurationId(),
4253
calculateScore(gameResultDTO),
4354
userId
4455
);
4556
try {
46-
resultClient.submit(resultDTO);
57+
resultClient.submit(accessToken, resultDTO);
4758
} catch (final FeignException.BadGateway badGateway) {
4859
final String warning =
4960
"The Overworld backend is currently not available. The result was NOT saved. Please try again later.";
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package de.unistuttgart.bugfinder.gameresult;
22

33
import org.springframework.cloud.openfeign.FeignClient;
4+
import org.springframework.web.bind.annotation.CookieValue;
45
import org.springframework.web.bind.annotation.PostMapping;
56

67
@FeignClient(value = "resultClient", url = "${overworld.url}/internal")
78
public interface ResultClient {
9+
/**
10+
* Submits the resultDTO to the Overworld-Backend
11+
*
12+
* @param accessToken the users access token
13+
* @param resultDTO the player submitted result, trimmed down to the data needed for the overworld
14+
*/
815
@PostMapping("/submit-game-pass")
9-
void submit(OverworldResultDTO resultDTO);
16+
void submit(@CookieValue("access_token") final String accessToken, final OverworldResultDTO resultDTO);
1017
}

0 commit comments

Comments
 (0)