mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-06 22:29:54 +02:00
nip-86: update methods.
This commit is contained in:
@ -72,6 +72,10 @@ func DecodeRequest(req Request) (MethodParams, error) {
|
|||||||
return BanEvent{id, reason}, nil
|
return BanEvent{id, reason}, nil
|
||||||
case "listbannedevents":
|
case "listbannedevents":
|
||||||
return ListBannedEvents{}, nil
|
return ListBannedEvents{}, nil
|
||||||
|
case "listallowedevents":
|
||||||
|
return ListAllowedEvents{}, nil
|
||||||
|
case "listdisallowedkinds":
|
||||||
|
return ListDisallowedKinds{}, nil
|
||||||
case "changerelayname":
|
case "changerelayname":
|
||||||
if len(req.Params) == 0 {
|
if len(req.Params) == 0 {
|
||||||
return nil, fmt.Errorf("invalid number of params for '%s'", req.Method)
|
return nil, fmt.Errorf("invalid number of params for '%s'", req.Method)
|
||||||
@ -140,6 +144,30 @@ func DecodeRequest(req Request) (MethodParams, error) {
|
|||||||
return UnblockIP{ip, reason}, nil
|
return UnblockIP{ip, reason}, nil
|
||||||
case "listblockedips":
|
case "listblockedips":
|
||||||
return ListBlockedIPs{}, nil
|
return ListBlockedIPs{}, nil
|
||||||
|
case "grantadmin":
|
||||||
|
if len(req.Params) < 2 {
|
||||||
|
return nil, fmt.Errorf("invalid number of params for '%s'", req.Method)
|
||||||
|
}
|
||||||
|
|
||||||
|
pubkey := req.Params[0].(string)
|
||||||
|
allowedMethods := req.Params[1].([]string)
|
||||||
|
|
||||||
|
return GrantAdmin{
|
||||||
|
Pubkey: pubkey,
|
||||||
|
AllowMethods: allowedMethods,
|
||||||
|
}, nil
|
||||||
|
case "revokeadmin":
|
||||||
|
if len(req.Params) < 2 {
|
||||||
|
return nil, fmt.Errorf("invalid number of params for '%s'", req.Method)
|
||||||
|
}
|
||||||
|
|
||||||
|
pubkey := req.Params[0].(string)
|
||||||
|
disallowedMethods := req.Params[1].([]string)
|
||||||
|
|
||||||
|
return RevokeAdmin{
|
||||||
|
Pubkey: pubkey,
|
||||||
|
DisallowMethods: disallowedMethods,
|
||||||
|
}, nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown method '%s'", req.Method)
|
return nil, fmt.Errorf("unknown method '%s'", req.Method)
|
||||||
}
|
}
|
||||||
@ -168,104 +196,130 @@ var (
|
|||||||
_ MethodParams = (*BlockIP)(nil)
|
_ MethodParams = (*BlockIP)(nil)
|
||||||
_ MethodParams = (*UnblockIP)(nil)
|
_ MethodParams = (*UnblockIP)(nil)
|
||||||
_ MethodParams = (*ListBlockedIPs)(nil)
|
_ MethodParams = (*ListBlockedIPs)(nil)
|
||||||
|
_ MethodParams = (*ListAllowedEvents)(nil)
|
||||||
|
_ MethodParams = (*ListDisallowedKinds)(nil)
|
||||||
|
_ MethodParams = (*GrantAdmin)(nil)
|
||||||
|
_ MethodParams = (*RevokeAdmin)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
type SupportedMethods struct{}
|
type SupportedMethods struct{}
|
||||||
|
|
||||||
func (_ SupportedMethods) MethodName() string { return "supportedmethods" }
|
func (SupportedMethods) MethodName() string { return "supportedmethods" }
|
||||||
|
|
||||||
type BanPubKey struct {
|
type BanPubKey struct {
|
||||||
PubKey string
|
PubKey string
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ BanPubKey) MethodName() string { return "banpubkey" }
|
func (BanPubKey) MethodName() string { return "banpubkey" }
|
||||||
|
|
||||||
type ListBannedPubKeys struct{}
|
type ListBannedPubKeys struct{}
|
||||||
|
|
||||||
func (_ ListBannedPubKeys) MethodName() string { return "listbannedpubkeys" }
|
func (ListBannedPubKeys) MethodName() string { return "listbannedpubkeys" }
|
||||||
|
|
||||||
type AllowPubKey struct {
|
type AllowPubKey struct {
|
||||||
PubKey string
|
PubKey string
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ AllowPubKey) MethodName() string { return "allowpubkey" }
|
func (AllowPubKey) MethodName() string { return "allowpubkey" }
|
||||||
|
|
||||||
type ListAllowedPubKeys struct{}
|
type ListAllowedPubKeys struct{}
|
||||||
|
|
||||||
func (_ ListAllowedPubKeys) MethodName() string { return "listallowedpubkeys" }
|
func (ListAllowedPubKeys) MethodName() string { return "listallowedpubkeys" }
|
||||||
|
|
||||||
type ListEventsNeedingModeration struct{}
|
type ListEventsNeedingModeration struct{}
|
||||||
|
|
||||||
func (_ ListEventsNeedingModeration) MethodName() string { return "listeventsneedingmoderation" }
|
func (ListEventsNeedingModeration) MethodName() string { return "listeventsneedingmoderation" }
|
||||||
|
|
||||||
type AllowEvent struct {
|
type AllowEvent struct {
|
||||||
ID string
|
ID string
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ AllowEvent) MethodName() string { return "allowevent" }
|
func (AllowEvent) MethodName() string { return "allowevent" }
|
||||||
|
|
||||||
type BanEvent struct {
|
type BanEvent struct {
|
||||||
ID string
|
ID string
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ BanEvent) MethodName() string { return "banevent" }
|
func (BanEvent) MethodName() string { return "banevent" }
|
||||||
|
|
||||||
type ListBannedEvents struct{}
|
type ListBannedEvents struct{}
|
||||||
|
|
||||||
func (_ ListBannedEvents) MethodName() string { return "listbannedevents" }
|
func (ListBannedEvents) MethodName() string { return "listbannedevents" }
|
||||||
|
|
||||||
type ChangeRelayName struct {
|
type ChangeRelayName struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ ChangeRelayName) MethodName() string { return "changerelayname" }
|
func (ChangeRelayName) MethodName() string { return "changerelayname" }
|
||||||
|
|
||||||
type ChangeRelayDescription struct {
|
type ChangeRelayDescription struct {
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ ChangeRelayDescription) MethodName() string { return "changerelaydescription" }
|
func (ChangeRelayDescription) MethodName() string { return "changerelaydescription" }
|
||||||
|
|
||||||
type ChangeRelayIcon struct {
|
type ChangeRelayIcon struct {
|
||||||
IconURL string
|
IconURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ ChangeRelayIcon) MethodName() string { return "changerelayicon" }
|
func (ChangeRelayIcon) MethodName() string { return "changerelayicon" }
|
||||||
|
|
||||||
type AllowKind struct {
|
type AllowKind struct {
|
||||||
Kind int
|
Kind int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ AllowKind) MethodName() string { return "allowkind" }
|
func (AllowKind) MethodName() string { return "allowkind" }
|
||||||
|
|
||||||
type DisallowKind struct {
|
type DisallowKind struct {
|
||||||
Kind int
|
Kind int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ DisallowKind) MethodName() string { return "disallowkind" }
|
func (DisallowKind) MethodName() string { return "disallowkind" }
|
||||||
|
|
||||||
type ListAllowedKinds struct{}
|
type ListAllowedKinds struct{}
|
||||||
|
|
||||||
func (_ ListAllowedKinds) MethodName() string { return "listallowedkinds" }
|
func (ListAllowedKinds) MethodName() string { return "listallowedkinds" }
|
||||||
|
|
||||||
type BlockIP struct {
|
type BlockIP struct {
|
||||||
IP net.IP
|
IP net.IP
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ BlockIP) MethodName() string { return "blockip" }
|
func (BlockIP) MethodName() string { return "blockip" }
|
||||||
|
|
||||||
type UnblockIP struct {
|
type UnblockIP struct {
|
||||||
IP net.IP
|
IP net.IP
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ UnblockIP) MethodName() string { return "unblockip" }
|
func (UnblockIP) MethodName() string { return "unblockip" }
|
||||||
|
|
||||||
type ListBlockedIPs struct{}
|
type ListBlockedIPs struct{}
|
||||||
|
|
||||||
func (_ ListBlockedIPs) MethodName() string { return "listblockedips" }
|
func (ListBlockedIPs) MethodName() string { return "listblockedips" }
|
||||||
|
|
||||||
|
type ListAllowedEvents struct{}
|
||||||
|
|
||||||
|
func (ListAllowedEvents) MethodName() string { return "listallowedevents" }
|
||||||
|
|
||||||
|
type ListDisallowedKinds struct{}
|
||||||
|
|
||||||
|
func (ListDisallowedKinds) MethodName() string { return "listdisallowedkinds" }
|
||||||
|
|
||||||
|
type GrantAdmin struct {
|
||||||
|
Pubkey string
|
||||||
|
AllowMethods []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (GrantAdmin) MethodName() string { return "grantadmin" }
|
||||||
|
|
||||||
|
type RevokeAdmin struct {
|
||||||
|
Pubkey string
|
||||||
|
DisallowMethods []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (RevokeAdmin) MethodName() string { return "revokeadmin" }
|
||||||
|
Reference in New Issue
Block a user