diff --git a/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt b/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt index 5a1af6e6..c034bea6 100644 --- a/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt +++ b/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt @@ -53,7 +53,7 @@ class AccountService( val fileName = fileUploader.buildFileName(it, dto.email) account.photo = fileUploader.uploadImage("profile", fileName, it.bytes) previousPhoto?.let { fileUploader.deleteImage(it) } - //This seems like it should be inside a try catch, but no db changes are, ask in next meet + // This seems like it should be inside a try catch, but no db changes are, ask in next meet } val newAccount = dto.update(account) @@ -74,10 +74,9 @@ class AccountService( } fun deleteAccountById(id: Long) { - val account = getAccountById(id) - ?: throw NoSuchElementException(ErrorMessages.accountNotFound(id)) + val account = getAccountById(id) - account.photo?.takeIf {it.isNotBlank() }?.let { photo -> + account.photo?.takeIf { it.isNotBlank() }?.let { photo -> fileUploader.deleteImage(photo) } repository.deleteById(id)