Skip to content

Commit fa1e517

Browse files
committed
Filter expired notes
1 parent 1b70f53 commit fa1e517

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/main/java/moe/echo/bramblingnote/note/Controller.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ private Note getNote(UUID id, UUID userId) throws ResponseStatusException {
7272
);
7373
}
7474

75+
if (note.getExpireAt() != null) {
76+
throw new ResponseStatusException(
77+
HttpStatusCode.valueOf(404),
78+
"Note `" + id + "` not found"
79+
);
80+
}
81+
7582
return note;
7683
}
7784

@@ -140,6 +147,7 @@ public List<NoteDto> getAll() {
140147
UserDto user = getUserFromSession();
141148

142149
return service.findAllByUserId(user.getId()).stream()
150+
.filter(note -> note.getExpireAt() == null)
143151
.map(note -> {
144152
NoteDto noteDto = noteMapper.toNoteDto(note);
145153
noteDto.setUser(user);

0 commit comments

Comments
 (0)