Skip to content

Commit 5f68978

Browse files
committed
Return value in delete operation.
1 parent d05925c commit 5f68978

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/main/kotlin/no/nav/klage/document/api/CommentsController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ class CommentsController(
141141
@PathVariable("documentId") documentId: UUID,
142142
@PathVariable("commentId") commentId: UUID,
143143
@RequestBody deleteCommentInput: DeleteCommentInput
144-
) {
144+
): Comment {
145145
log("deleteCommentWithPossibleThread called with id $documentId and commentId $commentId")
146-
commentService.deleteComment(commentId = commentId, loggedInIdent = getIdent()!!, behandlingTildeltIdent = deleteCommentInput.behandlingTildeltIdent)
146+
return commentService.deleteComment(commentId = commentId, loggedInIdent = getIdent()!!, behandlingTildeltIdent = deleteCommentInput.behandlingTildeltIdent)
147147
}
148148

149149
private fun mapCommentToView(comment: Comment): CommentView =

src/main/kotlin/no/nav/klage/document/service/CommentService.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,26 @@ class CommentService(private val commentRepository: CommentRepository) {
6969
commentId: UUID,
7070
loggedInIdent: String,
7171
behandlingTildeltIdent: String?
72-
) {
72+
): Comment {
7373
val loggedInIsDocumentOwner = loggedInIdent == behandlingTildeltIdent
7474
val comment = commentRepository.getReferenceById(commentId)
7575
if (!loggedInIsDocumentOwner && comment.authorIdent != loggedInIdent) {
7676
throw MissingAccessException("Not allowed to delete others comment when not document owner")
7777
}
78+
79+
val commentCopy = Comment(
80+
id = commentId,
81+
parentCommentId = comment.parentCommentId,
82+
documentId = comment.documentId,
83+
text = "",
84+
authorName = comment.authorName,
85+
authorIdent = comment.authorIdent,
86+
comments = comment.comments,
87+
created = comment.created,
88+
modified = LocalDateTime.now(),
89+
)
7890
commentRepository.delete(comment)
91+
92+
return commentCopy
7993
}
8094
}

0 commit comments

Comments
 (0)