diff --git a/core/services/link_service.go b/core/services/link_service.go index 2d28b6d..31ce992 100644 --- a/core/services/link_service.go +++ b/core/services/link_service.go @@ -2,8 +2,10 @@ package services import ( "context" + "log/slog" filehandling "github.com/KristianJBorgwarth/dendrite.daemon/core/file_handling" + "github.com/KristianJBorgwarth/dendrite.daemon/core/models" "github.com/KristianJBorgwarth/dendrite.daemon/persistence" "github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories" ) @@ -21,5 +23,12 @@ func NewLinkService(linkRepo repositories.ILinkRepository) ILinkService { } func (s *linkService) CreateLinks(ctx context.Context, dbCtx persistence.IDbContext, noteID string, links []*filehandling.ExtractedLink) error { - panic("not implemented") + if len(links) == 0 { + return nil + } + + linkModels := models.MapToLinkModel(noteID, links) + slog.Debug("Creating links", "noteID", noteID, "links", linkModels) + return s.linkRepo.Insert(ctx, dbCtx, linkModels) } +