Add possibility to share notes
This commit is contained in:
@@ -68,15 +68,28 @@ class NoteController(
|
||||
fun note(request: Request, jwtPayload: JwtPayload): Response {
|
||||
val noteUuid = request.uuidPath() ?: return Response(NOT_FOUND)
|
||||
|
||||
if (request.method == Method.POST && request.form("delete") != null) {
|
||||
return if (noteService.trash(jwtPayload.userId, noteUuid))
|
||||
Response.redirect("/notes") // TODO: flash cookie to show success ?
|
||||
else
|
||||
Response(NOT_FOUND) // TODO: show an error
|
||||
if (request.method == Method.POST) {
|
||||
if (request.form("delete") != null) {
|
||||
return if (noteService.trash(jwtPayload.userId, noteUuid))
|
||||
Response.redirect("/notes") // TODO: flash cookie to show success ?
|
||||
else
|
||||
Response(NOT_FOUND) // TODO: show an error
|
||||
}
|
||||
if (request.form("public") != null) {
|
||||
if (!noteService.makePublic(jwtPayload.userId, noteUuid)) return Response(NOT_FOUND)
|
||||
} else if (request.form("private") != null) {
|
||||
if (!noteService.makePrivate(jwtPayload.userId, noteUuid)) return Response(NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
val note = noteService.find(jwtPayload.userId, noteUuid) ?: return Response(NOT_FOUND)
|
||||
return Response(OK).html(view.renderedNote(jwtPayload, note))
|
||||
return Response(OK).html(view.renderedNote(jwtPayload, note, shared = false))
|
||||
}
|
||||
|
||||
fun public(request: Request, jwtPayload: JwtPayload?): Response {
|
||||
val noteUuid = request.uuidPath() ?: return Response(NOT_FOUND)
|
||||
val note = noteService.findPublic(noteUuid) ?: return Response(NOT_FOUND)
|
||||
return Response(OK).html(view.renderedNote(jwtPayload, note, shared = true))
|
||||
}
|
||||
|
||||
fun edit(request: Request, jwtPayload: JwtPayload): Response {
|
||||
|
||||
Reference in New Issue
Block a user