Skip to content

Commit

Permalink
WIP: Carddav
Browse files Browse the repository at this point in the history
  • Loading branch information
kreinhard committed Dec 11, 2024
1 parent 167290b commit 49cddf9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ internal class DeleteRequestHandler {
log.debug { "handleDeleteCall: ${requestWrapper.request.method}: '${requestWrapper.requestURI}' body=[${requestWrapper.body}]" }
val requestedPath = requestWrapper.requestURI
val contactId = CardDavUtils.extractContactId(requestedPath)
val contact = contactList.find { it.id == contactId }
if (contactId == null) {
log.info { "Contact with id=$contactId not found in personal contact list. Can't delete it." }
ResponseUtils.setValues(response, content = "The resource does not exist.", status = HttpStatus.NOT_FOUND)
return
}
if (addressService.deleteContact(contactId, contact)) {
if (addressService.deleteContact(contactId)) {
ResponseUtils.setValues(response, HttpStatus.NO_CONTENT)
} else {
ResponseUtils.setValues(response, content = "The resource does not exist.", status = HttpStatus.NOT_FOUND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ class AddressService {
return Contact()
}
*/
fun deleteContact(contactId: Long, contact: Contact?): Boolean {
fun deleteContact(contactId: Long): Boolean {
try {
val personalAddress = personalAddressDao.getByAddressId(contactId)
if (personalAddress?.isFavorite == true) {
personalAddress.isFavoriteCard = false
personalAddressDao.saveOrUpdate(personalAddress)
log.info("Contact #$contactId '${contact?.displayName}' removed from favorite list.")
log.info("Contact #$contactId removed from favorite list.")
}
return true
} catch (e: Exception) {
log.error(e) { "Exception while deleting contact: id=${contactId}, name=[${contact?.displayName}]" }
log.error(e) { "Exception while deleting contact: id=${contactId}." }
return false
}
}
Expand Down

0 comments on commit 49cddf9

Please sign in to comment.