[AB-xxx] fixing not being able to delete a giveaway key for which there is no giveaway

This commit is contained in:
Sheldan
2024-12-29 21:10:27 +01:00
parent 3ad8369ab3
commit 4ae6a154c7

View File

@@ -58,7 +58,9 @@ public class GiveawayKeyManagementServiceBean implements GiveawayKeyManagementSe
@Override
public void deleteById(Long id, Long serverId) {
GiveawayKey key = giveawayKeyRepository.findById(new GiveawayKeyId(id, serverId)).orElseThrow(GiveawayKeyNotFoundException::new);
key.getGiveaway().setGiveawayKey(null);
if(key.getGiveaway() != null) {
key.getGiveaway().setGiveawayKey(null);
}
giveawayKeyRepository.delete(key);
}