feat(create_note): minimal handler

This commit is contained in:
Kristian Borgwarth 2026-03-22 23:02:31 +01:00
parent 843b840583
commit 722b1dbbe7
2 changed files with 10 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"github.com/KristianJBorgwarth/dendrite.daemon/core/rpc" "github.com/KristianJBorgwarth/dendrite.daemon/core/rpc"
"github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories"
) )
type createNoteCommand struct { type createNoteCommand struct {
@ -14,7 +15,7 @@ type createNoteCommand struct {
} }
type CreateNoteHandler struct{ type CreateNoteHandler struct{
repository NoteRepository repository repositories.NoteRepository
} }
func (h CreateNoteHandler) Handle(params []byte) (any, *rpc.Error) { func (h CreateNoteHandler) Handle(params []byte) (any, *rpc.Error) {
@ -23,4 +24,11 @@ func (h CreateNoteHandler) Handle(params []byte) (any, *rpc.Error) {
return nil, &rpc.Error{Code: -32602, Message: "invalid params"} return nil, &rpc.Error{Code: -32602, Message: "invalid params"}
} }
err := h.repository.Upsert(cmd.Title, cmd.TemplatePath, cmd.Path)
if err != nil {
return nil, &rpc.Error{Code: -1, Message: err.Error()}
}
return map[string]any{"status": "ok"}, nil
} }

View file

@ -3,7 +3,7 @@ package repositories
import "database/sql" import "database/sql"
type NoteRepository interface { type NoteRepository interface {
CreateNote(title string, path string, slug string) error Upsert(title string, path string, slug string) error
} }
type noteRepository struct { type noteRepository struct {