From a9df9c6a2161d27f37019a10864ff81bc41870c9 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 20 Jul 2026 17:05:36 -0300 Subject: [PATCH] groups: nip29 parenting. --- go.mod | 4 +--- go.sum | 6 ++---- group.go | 31 ++++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 4bd9bf5..663c6e3 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 0f2954d..2199ef9 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/group.go b/group.go index 747ce1f..37ea1a0 100644 --- a/group.go +++ b/group.go @@ -29,7 +29,6 @@ var group = &cli.Command{ ArgsUsage: " ' [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 }) },