auto-create users on mention and resolve user refs in relationships

This commit is contained in:
2026-03-27 18:11:13 +01:00
parent 74cc7c104a
commit 9b250c20f9
3 changed files with 69 additions and 6 deletions

View File

@@ -31,18 +31,25 @@ var createCmd = &cobra.Command{
cTags = append(cTags, "_status::open")
}
if !slices.ContainsFunc(cTags, func(e string) bool { return strings.HasPrefix(e, "_namespace::") }) {
cTags = append(cTags, "_namespace::" + db.GetCurrentUser())
cTags = append(cTags, "_namespace::"+db.GetCurrentUser())
}
rels := make(map[models.RelType][]string)
relCreated := false
for _, r := range cRels {
rt, tgt, err := db.ParseRelFlag(r)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
if rt == models.RelCreated {
relCreated = true
}
rels[rt] = append(rels[rt], tgt)
}
if !relCreated {
rels[models.RelCreated] = append(rels[models.RelCreated], db.GetCurrentUser())
}
if n, err := d.CreateNode(db.CreateParams{Title: args[0], Content: cContent, DueDate: cDue, Tags: cTags, Rels: rels}); err != nil {
fmt.Fprintln(os.Stderr, "failed to create:", err)