groups: nip29 parenting.

This commit is contained in:
fiatjaf
2026-07-20 17:05:36 -03:00
parent 57be7627d4
commit a9df9c6a21
3 changed files with 33 additions and 8 deletions

4
go.mod
View File

@@ -3,7 +3,7 @@ module github.com/fiatjaf/nak
go 1.25
require (
fiatjaf.com/nostr v0.0.0-20260708142249-c591b5592910
fiatjaf.com/nostr v0.0.0-20260716191248-c205ed45b97e
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/bep/debounce v1.2.1
github.com/btcsuite/btcd/btcec/v2 v2.3.6
@@ -113,5 +113,3 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/qr v0.2.0 // indirect
)
replace fiatjaf.com/nostr => ../nostrlib

6
go.sum
View File

@@ -1,9 +1,7 @@
fiatjaf.com/lib v0.3.7 h1:mXZOn7NrUcjSdy4oNvwQyAmes7Ueb+Zr5hjqMIe2dxI=
fiatjaf.com/lib v0.3.7/go.mod h1:UlHaZvPHj25PtKLh9GjZkUHRmQ2xZ8Jkoa4VRaLeeQ8=
fiatjaf.com/nostr v0.0.0-20260625215907-7a78ad0c459f h1:n0G6XmIXS/j+AgDRFiZqK+l1R0ZahlPe/HwHlfxwj/c=
fiatjaf.com/nostr v0.0.0-20260625215907-7a78ad0c459f/go.mod h1:b1EIUDnd133Ie8Pg8O/biaKdFyCMz28aD4n64g1GqvM=
fiatjaf.com/nostr v0.0.0-20260708142249-c591b5592910 h1:LplP012gQeGf2hwMcUllEfDrZvyQR6zvrXSNaNVcm20=
fiatjaf.com/nostr v0.0.0-20260708142249-c591b5592910/go.mod h1:b1EIUDnd133Ie8Pg8O/biaKdFyCMz28aD4n64g1GqvM=
fiatjaf.com/nostr v0.0.0-20260716191248-c205ed45b97e h1:/vgoytiH4qQ28O/oX1hj656X69CnTy1pGj/17HFjH+A=
fiatjaf.com/nostr v0.0.0-20260716191248-c205ed45b97e/go.mod h1:b1EIUDnd133Ie8Pg8O/biaKdFyCMz28aD4n64g1GqvM=
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=

View File

@@ -29,7 +29,6 @@ var group = &cli.Command{
ArgsUsage: "<subcommand> <relay>'<identifier> [flags]",
Flags: combineFlags([][]cli.Flag{}),
Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
return ctx, nil
},
Commands: []*cli.Command{
@@ -696,6 +695,18 @@ write your forum post
Name: "all-kinds",
Usage: "specify this to delete the supported_kinds property, meaning everything will be supported",
},
&cli.StringFlag{
Name: "parent",
Usage: "set parent group identifier",
},
&cli.StringFlag{
Name: "children",
Usage: "set child group identifiers (semicolon-separated)",
},
&cli.BoolFlag{
Name: "orphan",
Usage: "remove parent tag, making this group an orphan",
},
},
Action: func(ctx context.Context, c *cli.Command) error {
relay, identifier, err := parseGroupIdentifier(c)
@@ -760,6 +771,18 @@ write your forum post
} else if c.Bool("all-kinds") {
group.SupportedKinds = nil
}
if parent := c.String("parent"); parent != "" {
group.Parent = parent
}
if children := c.String("children"); children != "" {
group.Children = strings.Split(children, ";")
for i := range group.Children {
group.Children[i] = strings.TrimSpace(group.Children[i])
}
}
if c.Bool("orphan") {
group.Parent = ""
}
return publishModerationEvent(ctx, c, 9002, func(evt *nostr.Event, args []string) error {
evt.Tags = append(evt.Tags, nostr.Tag{"name", group.Name})
@@ -790,6 +813,12 @@ write your forum post
}
evt.Tags = append(evt.Tags, tag)
}
if group.Parent != "" {
evt.Tags = append(evt.Tags, nostr.Tag{"parent", group.Parent})
}
for _, child := range group.Children {
evt.Tags = append(evt.Tags, nostr.Tag{"child", child})
}
return nil
})
},