auto-create users on mention and resolve user refs in relationships
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user