Author SHA1 Message Date
Elias Harb 4063160133 TripSeeder removed
LocationBasedServices/sumoc-backend/pipeline/pr-main This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
2026-02-25 18:54:20 +01:00
Elias Harb 427267c4bf Revert "Merge branch 'testPhase' of https://project.nes.uni-due.de/gitea/laaser/sumoc-backend into testPhase"
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/pr-main This commit looks good
This reverts commit 82b9ae15d9, reversing
changes made to 29e4096e95.
2026-02-25 18:41:10 +01:00
Elias Harb 82b9ae15d9 Merge branch 'testPhase' of https://project.nes.uni-due.de/gitea/laaser/sumoc-backend into testPhase
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
2026-02-25 18:40:22 +01:00
Elias Harb 29e4096e95 Setting up Gamification for test phase 2026-02-25 18:40:05 +01:00
Elias Harb 1d2c04d95c Setting up Gamification for test phase
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
2026-02-25 18:37:04 +01:00
harb 29956d0b92 Merge pull request 'Bug fix: getPicture Endpoint' (#24) from ChallengesDummyPics into main
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
Reviewed-on: #24
2026-02-25 01:58:26 +01:00
Elias Harb 932fc88b2e Bug fix: getPicture Endpoint
LocationBasedServices/sumoc-backend/pipeline/pr-main Build queued...
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
- got error that object was too large for transaction ... again
2026-02-25 01:55:10 +01:00
harb d7cb3c0e8e Merge pull request 'add challenge Dummy picture' (#23) from ChallengesDummyPics into main
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
Reviewed-on: #23
2026-02-25 00:23:27 +01:00
Elias Harb 7c347caea9 add challenge Dummy picture
LocationBasedServices/sumoc-backend/pipeline/pr-main Build queued...
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
2026-02-25 00:17:35 +01:00
kakoschke 29fb04d6ec Merge pull request 'make reset password Kotlin/Android app functional' (#22) from passwordResetRefactoring into main
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
Reviewed-on: #22

passt!
2026-02-23 18:47:33 +01:00
Elias Harb 82014b1d9c make reset password Kotlin/Android app functional
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/pr-main This commit looks good
- small refactor for resetPassword
2026-02-23 18:30:15 +01:00
neuhauss 57e9beb33f Merge pull request 'WIP FirebaseMessageBuilder.java adaptiert, sodass auch iOS Apps Push Benachrichtigungen erhalten und intercepten können.' (#21) from add-ios-notification into main
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
Reviewed-on: #21
2026-02-23 11:47:24 +01:00
12 changed files with 50 additions and 92 deletions
@@ -34,11 +34,11 @@ public interface ChallengeMapper {
challenge.setCriteria(dto.getCriteria());
challenge.setReward(dto.getReward());
if (dto.getBase64image() != null && !dto.getBase64image().isEmpty()) {
challenge.setImage(new ChallengeImageEntity(
challenge,
ImageBase64Util.decode(dto.getBase64image())
));
if (dto.getBase64image() != null && !dto.getBase64image().isBlank()) {
byte[] bytes = ImageBase64Util.decode(dto.getBase64image());
ChallengeImageEntity img = new ChallengeImageEntity();
img.setImageData(bytes);
challenge.setImage(img);
}
return challenge;
@@ -85,6 +85,9 @@ public class Challenge {
public void setImage(ChallengeImageEntity image) {
this.image = image;
if (image != null) {
image.setChallenge(this);
}
}
public Map<String, Integer> getCriteria() {
@@ -102,9 +102,11 @@ public class UserAuthenticationController {
authenticationService.resetPassword(passwordResetDTO);
return ResponseEntity.ok("Passwort erfolgreich geändert");
} catch (InvalidTokenException | UsernameNotFoundException e) {
e.printStackTrace();
return ResponseEntity.badRequest().body(e.getMessage());
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Fehler beim Zurücksetzen des Passworts");
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}
}
}
@@ -1,5 +1,6 @@
package SuMoC.backend.security.dtos;
import com.fasterxml.jackson.annotation.JsonAlias;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@@ -8,7 +9,9 @@ import lombok.Setter;
@Setter
@AllArgsConstructor
public class PasswordResetDTO {
String otp_code;
@JsonAlias({"otp_code", "otpCode"})
String otpCode;
String email;
String new_password;
@JsonAlias({"new_password", "newPassword"})
String newPassword;
}
@@ -17,12 +17,12 @@ public class PasswordResetToken{
private Long id;
private String email;
private String otp_code;
private String otpCode;
private LocalDateTime expiryDate;
public PasswordResetToken(String email, String code) {
this.email = email;
this.otp_code = code;
this.otpCode = code;
this.expiryDate = LocalDateTime.now().plusMinutes(EXPIRY_TIME_MINUTES);
}
@@ -13,8 +13,6 @@ import SuMoC.backend.user.models.User;
import SuMoC.backend.user.repository.UserRepository;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.mail.MailException;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -155,7 +153,6 @@ public class AuthenticationService {
});
String otp = generate_six_digit_OTP();
passwordResetTokenRepository.save(new PasswordResetToken(email, passwordEncoder.encode(otp))); //encoded otp
emailService.sendPasswordResetEmail(email, otp);
}
@@ -171,18 +168,17 @@ public class AuthenticationService {
}
//use .matches() so compare raw otp to (salted!) encoded otp
if(!passwordEncoder.matches(passwordResetDTO.getOtp_code(),token.getOtp_code())){
if(!passwordEncoder.matches(passwordResetDTO.getOtpCode(),token.getOtpCode())){
throw new InvalidTokenException("Code ist ungültig");
}
if(!isPasswordFormatCorrect(passwordResetDTO.getNew_password())) {
if(!isPasswordFormatCorrect(passwordResetDTO.getNewPassword())) {
throw new InvalidTokenException("Passwortformat ist nicht korrekt");
}
User user = userRepository.findByEmail(passwordResetDTO.getEmail())
.orElseThrow(() -> new UsernameNotFoundException("User existiert nicht"));
user.setPassword(passwordEncoder.encode(passwordResetDTO.getNew_password()));
user.setPassword(passwordEncoder.encode(passwordResetDTO.getNewPassword()));
userRepository.save(user);
passwordResetTokenRepository.delete(token);
}
@@ -1,11 +1,11 @@
package SuMoC.backend.gamification.badges;
package SuMoC.backend.seed;
import SuMoC.backend.gamification.badges.BadgeRepository;
import SuMoC.backend.gamification.badges.BadgeService;
import SuMoC.backend.gamification.badges.mapper.BadgeMapper;
import SuMoC.backend.gamification.badges.models.Badge;
import SuMoC.backend.gamification.badges.models.BadgeCategory;
import SuMoC.backend.gamification.badges.models.BadgeDTO;
import jakarta.transaction.Transactional;
import kotlin.collections.ArrayDeque;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
@@ -16,7 +16,7 @@ import java.util.*;
@Component
@Profile("dev")
@Order(3)
@Order(2)
public class DevBadgeSeeder implements CommandLineRunner {
private final BadgeService badgeService;
@@ -8,13 +8,15 @@ import jakarta.transaction.Transactional;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import java.io.InputStream;
import java.util.*;
@Component
@Profile("dev")
@Order(4)
@Order(3)
public class DevChallengeSeeder implements CommandLineRunner {
private final ChallengeService challengeService;
@@ -31,6 +33,7 @@ public class DevChallengeSeeder implements CommandLineRunner {
@Override
@Transactional
public void run(String... args) {
final String dummyImageBase64 = loadBase64FromClasspath("images/ChallengeDummy.png");
List<Seed> seeds = generateSeeds();
for (Seed seed : seeds) {
@@ -38,20 +41,20 @@ public class DevChallengeSeeder implements CommandLineRunner {
.map(ChallengeMapper::toDTO)
.ifPresentOrElse(
existingChallenge -> {
// Update existing challenge
existingChallenge.setName(seed.name());
existingChallenge.setDescription(seed.description());
existingChallenge.setCriteria(seed.criteria());
existingChallenge.setReward(seed.reward());
existingChallenge.setBase64image(dummyImageBase64);
challengeService.modifyChallenge(existingChallenge);
},
() -> {
// Create new challenge
ChallengeDTO newChallenge = new ChallengeDTO();
newChallenge.setName(seed.name());
newChallenge.setDescription(seed.description());
newChallenge.setCriteria(seed.criteria());
newChallenge.setReward(seed.reward());
newChallenge.setBase64image(dummyImageBase64);
challengeService.createChallenge(newChallenge);
}
);
@@ -60,6 +63,15 @@ public class DevChallengeSeeder implements CommandLineRunner {
challengeService.weeklyChallengeScheduler();
}
private String loadBase64FromClasspath(String classpathLocation) {
try (InputStream in = new ClassPathResource(classpathLocation).getInputStream()) {
byte[] bytes = in.readAllBytes();
return Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
throw new IllegalStateException("Could not load image from classpath: " + classpathLocation, e);
}
}
private record Seed(String name, String description, Map<String, Integer> criteria, Integer reward) {}
private static Seed seed(
@@ -1,57 +0,0 @@
package SuMoC.backend.seed.trip;
import SuMoC.backend.trip.TripFactory;
import SuMoC.backend.trip.TripService;
import SuMoC.backend.trip.dtos.NewTripDTO;
import SuMoC.backend.user.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Component
@Profile("dev")
@Order(2)
public class DevTripSeeder implements CommandLineRunner {
private final TripService tripService;
private final UserRepository userRepository;
@Autowired
public DevTripSeeder(TripService tripService, UserRepository userRepository) {
this.tripService = tripService;
this.userRepository = userRepository;
}
@Override
public void run(String... args) throws Exception {
// Iterate over all users and create 5 random trips for each of the last 5 weeks + adds car trips for every day at same time
userRepository.findAll().forEach(user -> {
for (int week = 0; week < 5; week++) {
for (int day = 0; day < 7; day++) {
// NewTripDTO carTrip = TripFactory.newCarTripDTO(
// Instant.now()
// .minus(Duration.ofDays(week * 7 + day)).atZone(ZoneId.systemDefault()).toInstant()
// );
// This should definitly trigger regularTripDetection
NewTripDTO triggerCarTrip = TripFactory.newTriggeringCarMock(
java.time.Instant.now().minus(java.time.Duration.ofDays(week * 7 + day))
);
tripService.addTrip(user, triggerCarTrip);
}
// Create 5 trips per week
// for (int i = 0; i < 5; i++) {
// // Create trips within each week's time range
// long daysAgo = week * 7 + (long) (Math.random() * 7);
// NewTripDTO newTrip = TripFactory.randomNewTripDTO(
// java.time.Instant.now().minus(java.time.Duration.ofDays((long) (Math.random() * 30))));
// tripService.addTrip(user, newTrip);
// }
}
});
}
}
@@ -45,11 +45,11 @@ public class DevUserSeeder implements CommandLineRunner {
Long positionIndex = 1L;
for (var user : pgMembers) {
addDummyStats(user, positionIndex);
addDummyStats(user);
positionIndex++;
}
for (var user : defaultTestUsers) {
addDummyStats(user, positionIndex);
addDummyStats(user);
positionIndex++;
}
//List<User> nTestUsers = seedNtestUsers(10);
@@ -261,31 +261,31 @@ public class DevUserSeeder implements CommandLineRunner {
return createdUsers;
}
private void addDummyStats(User user, Long positionIndex) {
private void addDummyStats(User user) {
user.getStats().addToStat(
Timeframe.WEEKLY,
"XP",
100L * positionIndex
0
);
user.getStats().addToStat(
Timeframe.WEEKLY,
"CO2_SAVED",
500L * positionIndex
0
);
user.getStats().addToStat(
Timeframe.WEEKLY,
"KM_CYCLED",
20L * positionIndex
0
);
user.getStats().addToStat(
Timeframe.WEEKLY,
"KM_WALKED",
10L * positionIndex
0
);
user.getStats().addToStat(
Timeframe.WEEKLY,
"KM_PUBLIC_TRANSPORT",
15L * positionIndex
0
);
userRepository.save(user);
}
@@ -233,16 +233,15 @@ public class UserController {
@ApiResponse(responseCode = "403", description = "Only authorized persons may see the profiles picture"),
@ApiResponse(responseCode = "404", description = "The user does not exist")
})
@GetMapping("/getProfilePicture/{id}")
@GetMapping(value = "/getProfilePicture/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ImageRequestDTO> getProfilePicture(@PathVariable @NotNull Long id) {
ImageRequestDTO imageData = userService.getProfilePicture(id);
return ResponseEntity.ok()
.contentType(MediaType.IMAGE_JPEG)
.contentType(MediaType.APPLICATION_JSON)
.cacheControl(CacheControl.maxAge(365, TimeUnit.DAYS))
.body(imageData);
}
@Operation(summary = "Get the users own xp", description = "A user can get their own xp.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "XP successfully retrieved",
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB