diff --git a/core/handlers/create_note_handler.go b/core/handlers/create_note_handler.go index 99310a9..48f4c5f 100644 --- a/core/handlers/create_note_handler.go +++ b/core/handlers/create_note_handler.go @@ -36,6 +36,7 @@ func (h *CreateNoteHandler) Handle(ctx context.Context, raw json.RawMessage) (an slug := frontmatter.Slugify(cmd.Title) templatePath := store.GetVaultStore().GetTemplatePath(cmd.TemplateName) + notePath := store.GetVaultStore().Config.VaultPath() + "/" + cmd.Directory + "/" + slug + ".md" data, err := template.RenderTemplate(templatePath, cmd.Title, slug) if err != nil { @@ -82,7 +83,7 @@ func (h *CreateNoteHandler) Handle(ctx context.Context, raw json.RawMessage) (an tagModels = append(tagModels, dbTags...) - note := models.CreateNote(cmd.Directory, cmd.Title, slug) + note := models.CreateNote(notePath, cmd.Title, slug) if err = noteRepo.Upsert(ctx, note); err != nil { return nil, err diff --git a/dendrite b/dendrite index 48fff04..6b7fd73 100755 Binary files a/dendrite and b/dendrite differ diff --git a/test/test_integration/create_note_handler_test.go b/test/test_integration/create_note_handler_test.go index 28f085e..d182269 100644 --- a/test/test_integration/create_note_handler_test.go +++ b/test/test_integration/create_note_handler_test.go @@ -18,7 +18,8 @@ func TestCreateNoteHandler_NoTemplate_CreatesNoteFileAndReturnsPath(t *testing.T notePath := filepath.Join(t.TempDir(), "my-note.md") params, _ := json.Marshal(map[string]any{ "title": "My Note", - "path": notePath, + "templateName": "", + "directory": "", }) // Act diff --git a/test/test_integration/main_test.go b/test/test_integration/main_test.go index 94fd8dd..05acda7 100644 --- a/test/test_integration/main_test.go +++ b/test/test_integration/main_test.go @@ -5,11 +5,13 @@ import ( "database/sql" "encoding/json" "os" + "path" "path/filepath" "testing" "github.com/KristianJBorgwarth/dendrite.daemon/core/rpc" "github.com/KristianJBorgwarth/dendrite.daemon/persistence" + "github.com/KristianJBorgwarth/dendrite.daemon/persistence/store" _ "modernc.org/sqlite" ) @@ -17,6 +19,7 @@ type DBFixture struct { DB *sql.DB DBPath string TestContext context.Context + VaultStore *store.VaultStore } func NewDBFixture() *DBFixture { @@ -35,6 +38,7 @@ func NewDBFixture() *DBFixture { DB: dbContext.DB, DBPath: dbPath, TestContext: context.Background(), + VaultStore: store.NewVaultStore(vaultPath, path.Join(vaultPath, "templates")), } }