2 Commits

Author SHA1 Message Date
mplorentz 662e7d271c Add KindSimpleGroupLiveKitParticipants (#1)
Add kind 39004 so that zooid can publish active livekit participants.

Co-authored-by: Matt Lorentz <mplorentz@noreply.coracle.social>
Co-committed-by: Matt Lorentz <mplorentz@noreply.coracle.social>
2026-03-13 09:49:27 -07:00
Jon Staab d6812c040a Add unbanpubkey and unallowpubkey 2026-02-25 19:31:37 -08:00
4 changed files with 206 additions and 132 deletions
+18
View File
@@ -21,8 +21,10 @@ type RelayManagementAPI struct {
BanPubKey func(ctx context.Context, pubkey nostr.PubKey, reason string) error BanPubKey func(ctx context.Context, pubkey nostr.PubKey, reason string) error
ListBannedPubKeys func(ctx context.Context) ([]nip86.PubKeyReason, error) ListBannedPubKeys func(ctx context.Context) ([]nip86.PubKeyReason, error)
UnbanPubKey func(ctx context.Context, pubkey nostr.PubKey, reason string) error
AllowPubKey func(ctx context.Context, pubkey nostr.PubKey, reason string) error AllowPubKey func(ctx context.Context, pubkey nostr.PubKey, reason string) error
ListAllowedPubKeys func(ctx context.Context) ([]nip86.PubKeyReason, error) ListAllowedPubKeys func(ctx context.Context) ([]nip86.PubKeyReason, error)
UnallowPubKey func(ctx context.Context, pubkey nostr.PubKey, reason string) error
ListEventsNeedingModeration func(ctx context.Context) ([]nip86.IDReason, error) ListEventsNeedingModeration func(ctx context.Context) ([]nip86.IDReason, error)
AllowEvent func(ctx context.Context, id nostr.ID, reason string) error AllowEvent func(ctx context.Context, id nostr.ID, reason string) error
BanEvent func(ctx context.Context, id nostr.ID, reason string) error BanEvent func(ctx context.Context, id nostr.ID, reason string) error
@@ -168,6 +170,14 @@ func (rl *Relay) HandleNIP86(w http.ResponseWriter, r *http.Request) {
} else { } else {
resp.Result = result resp.Result = result
} }
case nip86.UnbanPubKey:
if rl.ManagementAPI.UnbanPubKey == nil {
resp.Error = fmt.Sprintf("method %s not supported", thing.MethodName())
} else if err := rl.ManagementAPI.UnbanPubKey(ctx, thing.PubKey, thing.Reason); err != nil {
resp.Error = err.Error()
} else {
resp.Result = true
}
case nip86.AllowPubKey: case nip86.AllowPubKey:
if rl.ManagementAPI.AllowPubKey == nil { if rl.ManagementAPI.AllowPubKey == nil {
resp.Error = fmt.Sprintf("method %s not supported", thing.MethodName()) resp.Error = fmt.Sprintf("method %s not supported", thing.MethodName())
@@ -184,6 +194,14 @@ func (rl *Relay) HandleNIP86(w http.ResponseWriter, r *http.Request) {
} else { } else {
resp.Result = result resp.Result = result
} }
case nip86.UnallowPubKey:
if rl.ManagementAPI.UnallowPubKey == nil {
resp.Error = fmt.Sprintf("method %s not supported", thing.MethodName())
} else if err := rl.ManagementAPI.UnallowPubKey(ctx, thing.PubKey, thing.Reason); err != nil {
resp.Error = err.Error()
} else {
resp.Result = true
}
case nip86.BanEvent: case nip86.BanEvent:
if rl.ManagementAPI.BanEvent == nil { if rl.ManagementAPI.BanEvent == nil {
resp.Error = fmt.Sprintf("method %s not supported", thing.MethodName()) resp.Error = fmt.Sprintf("method %s not supported", thing.MethodName())
+3
View File
@@ -246,6 +246,8 @@ func (kind Kind) Name() string {
return "SimpleGroupMembers" return "SimpleGroupMembers"
case KindSimpleGroupRoles: case KindSimpleGroupRoles:
return "SimpleGroupRoles" return "SimpleGroupRoles"
case KindSimpleGroupLiveKitParticipants:
return "SimpleGroupLiveKitParticipants"
case KindWikiArticle: case KindWikiArticle:
return "WikiArticle" return "WikiArticle"
case KindRedirects: case KindRedirects:
@@ -396,6 +398,7 @@ const (
KindSimpleGroupAdmins Kind = 39001 KindSimpleGroupAdmins Kind = 39001
KindSimpleGroupMembers Kind = 39002 KindSimpleGroupMembers Kind = 39002
KindSimpleGroupRoles Kind = 39003 KindSimpleGroupRoles Kind = 39003
KindSimpleGroupLiveKitParticipants Kind = 39004
KindWikiArticle Kind = 30818 KindWikiArticle Kind = 30818
KindRedirects Kind = 30819 KindRedirects Kind = 30819
KindFeed Kind = 31890 KindFeed Kind = 31890
+1
View File
@@ -28,6 +28,7 @@ var MetadataEventKinds = KindRange{
nostr.KindSimpleGroupAdmins, nostr.KindSimpleGroupAdmins,
nostr.KindSimpleGroupMembers, nostr.KindSimpleGroupMembers,
nostr.KindSimpleGroupRoles, nostr.KindSimpleGroupRoles,
nostr.KindSimpleGroupLiveKitParticipants,
} }
func (kr KindRange) Includes(kind nostr.Kind) bool { func (kr KindRange) Includes(kind nostr.Kind) bool {
+52
View File
@@ -32,6 +32,24 @@ func DecodeRequest(req Request) (MethodParams, error) {
return BanPubKey{pk, reason}, nil return BanPubKey{pk, reason}, nil
case "listbannedpubkeys": case "listbannedpubkeys":
return ListBannedPubKeys{}, nil return ListBannedPubKeys{}, nil
case "unbanpubkey":
if len(req.Params) == 0 {
return nil, fmt.Errorf("invalid number of params for '%s'", req.Method)
}
pkh, ok := req.Params[0].(string)
if !ok {
return nil, fmt.Errorf("missing pubkey param for '%s'", req.Method)
}
pk, err := nostr.PubKeyFromHex(pkh)
if err != nil {
return nil, fmt.Errorf("invalid pubkey param for '%s'", req.Method)
}
var reason string
if len(req.Params) >= 2 {
reason, _ = req.Params[1].(string)
}
return UnbanPubKey{pk, reason}, nil
case "allowpubkey": case "allowpubkey":
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)
@@ -52,6 +70,24 @@ func DecodeRequest(req Request) (MethodParams, error) {
return AllowPubKey{pk, reason}, nil return AllowPubKey{pk, reason}, nil
case "listallowedpubkeys": case "listallowedpubkeys":
return ListAllowedPubKeys{}, nil return ListAllowedPubKeys{}, nil
case "unallowpubkey":
if len(req.Params) == 0 {
return nil, fmt.Errorf("invalid number of params for '%s'", req.Method)
}
pkh, ok := req.Params[0].(string)
if !ok {
return nil, fmt.Errorf("missing pubkey param for '%s'", req.Method)
}
pk, err := nostr.PubKeyFromHex(pkh)
if err != nil {
return nil, fmt.Errorf("invalid pubkey param for '%s'", req.Method)
}
var reason string
if len(req.Params) >= 2 {
reason, _ = req.Params[1].(string)
}
return UnallowPubKey{pk, reason}, nil
case "listeventsneedingmoderation": case "listeventsneedingmoderation":
return ListEventsNeedingModeration{}, nil return ListEventsNeedingModeration{}, nil
case "allowevent": case "allowevent":
@@ -219,8 +255,10 @@ var (
_ MethodParams = (*SupportedMethods)(nil) _ MethodParams = (*SupportedMethods)(nil)
_ MethodParams = (*BanPubKey)(nil) _ MethodParams = (*BanPubKey)(nil)
_ MethodParams = (*ListBannedPubKeys)(nil) _ MethodParams = (*ListBannedPubKeys)(nil)
_ MethodParams = (*UnbanPubKey)(nil)
_ MethodParams = (*AllowPubKey)(nil) _ MethodParams = (*AllowPubKey)(nil)
_ MethodParams = (*ListAllowedPubKeys)(nil) _ MethodParams = (*ListAllowedPubKeys)(nil)
_ MethodParams = (*UnallowPubKey)(nil)
_ MethodParams = (*ListEventsNeedingModeration)(nil) _ MethodParams = (*ListEventsNeedingModeration)(nil)
_ MethodParams = (*AllowEvent)(nil) _ MethodParams = (*AllowEvent)(nil)
_ MethodParams = (*BanEvent)(nil) _ MethodParams = (*BanEvent)(nil)
@@ -256,6 +294,13 @@ type ListBannedPubKeys struct{}
func (ListBannedPubKeys) MethodName() string { return "listbannedpubkeys" } func (ListBannedPubKeys) MethodName() string { return "listbannedpubkeys" }
type UnbanPubKey struct {
PubKey nostr.PubKey
Reason string
}
func (UnbanPubKey) MethodName() string { return "unbanpubkey" }
type AllowPubKey struct { type AllowPubKey struct {
PubKey nostr.PubKey PubKey nostr.PubKey
Reason string Reason string
@@ -267,6 +312,13 @@ type ListAllowedPubKeys struct{}
func (ListAllowedPubKeys) MethodName() string { return "listallowedpubkeys" } func (ListAllowedPubKeys) MethodName() string { return "listallowedpubkeys" }
type UnallowPubKey struct {
PubKey nostr.PubKey
Reason string
}
func (UnallowPubKey) MethodName() string { return "unallowpubkey" }
type ListEventsNeedingModeration struct{} type ListEventsNeedingModeration struct{}
func (ListEventsNeedingModeration) MethodName() string { return "listeventsneedingmoderation" } func (ListEventsNeedingModeration) MethodName() string { return "listeventsneedingmoderation" }