@@ -493,63 +493,113 @@ var group = &cli.Command{
493493 Name : "no-livekit" ,
494494 },
495495 & cli.IntSliceFlag {
496- Name : "supported- kind" ,
496+ Name : "kind" ,
497497 Aliases : []string {"supported-kinds" },
498498 Usage : "list of event kind numbers supported by this group" ,
499499 },
500+ & cli.BoolFlag {
501+ Name : "all-kinds" ,
502+ Usage : "specify this to delete the supported_kinds property, meaning everything will be supported" ,
503+ },
500504 },
501505 Action : func (ctx context.Context , c * cli.Command ) error {
506+ relay , identifier , err := parseGroupIdentifier (c )
507+ if err != nil {
508+ return err
509+ }
510+
502511 if c .Bool ("livekit" ) || c .Bool ("no-livekit" ) {
503- relay , _ , err := parseGroupIdentifier (c )
504- if err != nil {
512+ if err := checkRelayLivekitMetadataSupport (ctx , relay ); err != nil {
505513 return err
506514 }
515+ }
507516
508- if err := checkRelayLivekitMetadataSupport (ctx , relay ); err != nil {
509- return err
517+ group , err := fetchGroupMetadata (ctx , relay , identifier )
518+ if err != nil {
519+ return err
520+ }
521+ if group .Name == "" {
522+ group .Name = identifier
523+ }
524+
525+ if name := c .String ("name" ); name != "" {
526+ group .Name = name
527+ }
528+ if picture := c .String ("picture" ); picture != "" {
529+ group .Picture = picture
530+ }
531+ if about := c .String ("about" ); about != "" {
532+ group .About = about
533+ }
534+ if c .Bool ("restricted" ) {
535+ group .Restricted = true
536+ } else if c .Bool ("unrestricted" ) {
537+ group .Restricted = false
538+ }
539+ if c .Bool ("closed" ) {
540+ group .Closed = true
541+ } else if c .Bool ("open" ) {
542+ group .Closed = false
543+ }
544+ if c .Bool ("hidden" ) {
545+ group .Hidden = true
546+ } else if c .Bool ("visible" ) {
547+ group .Hidden = false
548+ }
549+ if c .Bool ("private" ) {
550+ group .Private = true
551+ } else if c .Bool ("public" ) {
552+ group .Private = false
553+ }
554+ if c .Bool ("livekit" ) {
555+ group .LiveKit = true
556+ } else if c .Bool ("no-livekit" ) {
557+ group .LiveKit = false
558+ }
559+ if supportedKinds := c .IntSlice ("kind" ); len (supportedKinds ) > 0 {
560+ kinds := make ([]nostr.Kind , 0 , len (supportedKinds ))
561+ for _ , kind := range supportedKinds {
562+ kinds = append (kinds , nostr .Kind (kind ))
510563 }
564+ group .SupportedKinds = kinds
565+ } else if c .Bool ("all-kinds" ) {
566+ group .SupportedKinds = nil
511567 }
512568
513569 return createModerationEvent (ctx , c , 9002 , func (evt * nostr.Event , args []string ) error {
514- if name := c .String ("name" ); name != "" {
515- evt .Tags = append (evt .Tags , nostr.Tag {"name" , name })
516- }
517- if picture := c .String ("picture" ); picture != "" {
518- evt .Tags = append (evt .Tags , nostr.Tag {"picture" , picture })
519- }
520- if about := c .String ("about" ); about != "" {
521- evt .Tags = append (evt .Tags , nostr.Tag {"about" , about })
522- }
523- if c .Bool ("restricted" ) {
570+ evt .Tags = append (evt .Tags , nostr.Tag {"name" , group .Name })
571+ evt .Tags = append (evt .Tags , nostr.Tag {"picture" , group .Picture })
572+ evt .Tags = append (evt .Tags , nostr.Tag {"about" , group .About })
573+ if group .Restricted {
524574 evt .Tags = append (evt .Tags , nostr.Tag {"restricted" })
525- } else if c . Bool ( "unrestricted" ) {
575+ } else {
526576 evt .Tags = append (evt .Tags , nostr.Tag {"unrestricted" })
527577 }
528- if c . Bool ( "closed" ) {
578+ if group . Closed {
529579 evt .Tags = append (evt .Tags , nostr.Tag {"closed" })
530- } else if c . Bool ( "open" ) {
580+ } else {
531581 evt .Tags = append (evt .Tags , nostr.Tag {"open" })
532582 }
533- if c . Bool ( "hidden" ) {
583+ if group . Hidden {
534584 evt .Tags = append (evt .Tags , nostr.Tag {"hidden" })
535- } else if c . Bool ( "visible" ) {
585+ } else {
536586 evt .Tags = append (evt .Tags , nostr.Tag {"visible" })
537587 }
538- if c . Bool ( "private" ) {
588+ if group . Private {
539589 evt .Tags = append (evt .Tags , nostr.Tag {"private" })
540- } else if c . Bool ( "public" ) {
590+ } else {
541591 evt .Tags = append (evt .Tags , nostr.Tag {"public" })
542592 }
543- if c . Bool ( "livekit" ) {
593+ if group . LiveKit {
544594 evt .Tags = append (evt .Tags , nostr.Tag {"livekit" })
545- } else if c . Bool ( "no-livekit" ) {
595+ } else {
546596 evt .Tags = append (evt .Tags , nostr.Tag {"no-livekit" })
547597 }
548- if supportedKinds := c . IntSlice ( "supported-kind" ); len ( supportedKinds ) > 0 {
549- tag := make (nostr.Tag , 1 , 1 + len (supportedKinds ))
598+ if group . SupportedKinds != nil {
599+ tag := make (nostr.Tag , 1 , 1 + len (group . SupportedKinds ))
550600 tag [0 ] = "supported_kinds"
551- for _ , kind := range supportedKinds {
552- tag = append (tag , strconv .FormatInt ( kind , 10 ))
601+ for _ , kind := range group . SupportedKinds {
602+ tag = append (tag , strconv .Itoa ( int ( kind ) ))
553603 }
554604 evt .Tags = append (evt .Tags , tag )
555605 }
@@ -675,6 +725,7 @@ func fetchGroupMetadata(ctx context.Context, relay string, identifier string) (n
675725 filter := nostr.Filter {
676726 Kinds : []nostr.Kind {nostr .KindSimpleGroupMetadata },
677727 Tags : nostr.TagMap {"d" : []string {identifier }},
728+ Limit : 1 ,
678729 }
679730
680731 if info , err := nip11 .Fetch (ctx , relay ); err == nil {
0 commit comments