Skip to content

Commit 46a809d

Browse files
committed
admin: new nip86 "role" commands.
1 parent cbfc16f commit 46a809d

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

admin.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ var admin = &cli.Command{
4747
{"blockip", []string{"ip", "reason"}},
4848
{"unblockip", []string{"ip", "reason"}},
4949
{"listblockedips", nil},
50+
{"listallowedevents", nil},
51+
{"listdisallowedkinds", nil},
52+
{"supportedmethods", nil},
53+
{"stats", nil},
54+
{"grantadmin", []string{"pubkey", "methods"}},
55+
{"revokeadmin", []string{"pubkey", "methods"}},
56+
{"createrole", []string{"role_id", "label", "description", "color", "order"}},
57+
{"editrole", []string{"role_id", "label", "description", "color", "order"}},
58+
{"deleterole", []string{"role_id"}},
59+
{"assignrole", []string{"pubkey", "role_id"}},
60+
{"unassignrole", []string{"pubkey", "role_id"}},
5061
}
5162

5263
commands := make([]*cli.Command, 0, len(methods))
@@ -166,19 +177,31 @@ var admin = &cli.Command{
166177
func declareFlag(argName string) cli.Flag {
167178
usage := "parameter for this management RPC call, see https://nips.nostr.com/86 for more information."
168179
switch argName {
169-
case "kind":
180+
case "pubkey":
181+
return &PubKeyFlag{Name: argName, Usage: usage}
182+
case "id":
183+
return &IDFlag{Name: argName, Usage: usage}
184+
case "kind", "order":
170185
return &cli.IntFlag{Name: argName, Required: true, Usage: usage}
171186
case "reason":
172187
return &cli.StringFlag{Name: argName, Usage: usage}
188+
case "methods":
189+
return &cli.StringSliceFlag{Name: argName, Required: true, Usage: usage}
173190
default:
174191
return &cli.StringFlag{Name: argName, Required: true, Usage: usage}
175192
}
176193
}
177194

178195
func getArgument(c *cli.Command, argName string) any {
179196
switch argName {
180-
case "kind":
197+
case "pubkey":
198+
return getPubKey(c, argName)
199+
case "id":
200+
return getID(c, argName)
201+
case "kind", "order":
181202
return c.Int(argName)
203+
case "methods":
204+
return c.StringSlice(argName)
182205
default:
183206
return c.String(argName)
184207
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/fiatjaf/nak
33
go 1.25
44

55
require (
6-
fiatjaf.com/nostr v0.0.0-20260620232658-8389bac80c5f
6+
fiatjaf.com/nostr v0.0.0-20260625201206-404203b6ac1d
77
github.com/AlecAivazis/survey/v2 v2.3.7
88
github.com/bep/debounce v1.2.1
99
github.com/btcsuite/btcd/btcec/v2 v2.3.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fiatjaf.com/lib v0.3.7 h1:mXZOn7NrUcjSdy4oNvwQyAmes7Ueb+Zr5hjqMIe2dxI=
22
fiatjaf.com/lib v0.3.7/go.mod h1:UlHaZvPHj25PtKLh9GjZkUHRmQ2xZ8Jkoa4VRaLeeQ8=
3-
fiatjaf.com/nostr v0.0.0-20260620232658-8389bac80c5f h1:dl17ebu+HhtHTS9AdOc27TDUGfSjYVEO4qYLHEwjxOw=
4-
fiatjaf.com/nostr v0.0.0-20260620232658-8389bac80c5f/go.mod h1:b1EIUDnd133Ie8Pg8O/biaKdFyCMz28aD4n64g1GqvM=
3+
fiatjaf.com/nostr v0.0.0-20260625201206-404203b6ac1d h1:0Y+62o+HxN+SEF7btTHx9pkAU2A/tfgR4AFR1Emtl40=
4+
fiatjaf.com/nostr v0.0.0-20260625201206-404203b6ac1d/go.mod h1:b1EIUDnd133Ie8Pg8O/biaKdFyCMz28aD4n64g1GqvM=
55
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
66
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
77
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=

0 commit comments

Comments
 (0)