mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 13:22:56 +01:00
replace usage of IsValidPublicKeyHex() in subpackages.
This commit is contained in:
parent
9457c5a794
commit
2586144a5c
@ -150,7 +150,7 @@ func (group *Group) MergeInAdminsEvent(evt *nostr.Event) error {
|
|||||||
if tag[0] != "p" {
|
if tag[0] != "p" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !nostr.IsValidPublicKeyHex(tag[1]) {
|
if !nostr.IsValid32ByteHex(tag[1]) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ func (group *Group) MergeInMembersEvent(evt *nostr.Event) error {
|
|||||||
if tag[0] != "p" {
|
if tag[0] != "p" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !nostr.IsValidPublicKeyHex(tag[1]) {
|
if !nostr.IsValid32ByteHex(tag[1]) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
|
|||||||
nostr.KindSimpleGroupAddUser: func(evt *nostr.Event) (Action, error) {
|
nostr.KindSimpleGroupAddUser: func(evt *nostr.Event) (Action, error) {
|
||||||
targets := make([]string, 0, len(evt.Tags))
|
targets := make([]string, 0, len(evt.Tags))
|
||||||
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
||||||
if !nostr.IsValidPublicKeyHex(tag[1]) {
|
if !nostr.IsValid32ByteHex(tag[1]) {
|
||||||
return nil, fmt.Errorf("")
|
return nil, fmt.Errorf("")
|
||||||
}
|
}
|
||||||
targets = append(targets, tag[1])
|
targets = append(targets, tag[1])
|
||||||
@ -37,7 +37,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
|
|||||||
nostr.KindSimpleGroupRemoveUser: func(evt *nostr.Event) (Action, error) {
|
nostr.KindSimpleGroupRemoveUser: func(evt *nostr.Event) (Action, error) {
|
||||||
targets := make([]string, 0, len(evt.Tags))
|
targets := make([]string, 0, len(evt.Tags))
|
||||||
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
||||||
if !nostr.IsValidPublicKeyHex(tag[1]) {
|
if !nostr.IsValid32ByteHex(tag[1]) {
|
||||||
return nil, fmt.Errorf("invalid public key hex")
|
return nil, fmt.Errorf("invalid public key hex")
|
||||||
}
|
}
|
||||||
targets = append(targets, tag[1])
|
targets = append(targets, tag[1])
|
||||||
@ -81,7 +81,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
|
|||||||
|
|
||||||
targets := make([]string, 0, nTags-1)
|
targets := make([]string, 0, nTags-1)
|
||||||
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
||||||
if !nostr.IsValidPublicKeyHex(tag[1]) {
|
if !nostr.IsValid32ByteHex(tag[1]) {
|
||||||
return nil, fmt.Errorf("invalid public key hex")
|
return nil, fmt.Errorf("invalid public key hex")
|
||||||
}
|
}
|
||||||
targets = append(targets, tag[1])
|
targets = append(targets, tag[1])
|
||||||
@ -107,7 +107,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
|
|||||||
|
|
||||||
targets := make([]string, 0, nTags-1)
|
targets := make([]string, 0, nTags-1)
|
||||||
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
|
||||||
if !nostr.IsValidPublicKeyHex(tag[1]) {
|
if !nostr.IsValid32ByteHex(tag[1]) {
|
||||||
return nil, fmt.Errorf("invalid public key hex")
|
return nil, fmt.Errorf("invalid public key hex")
|
||||||
}
|
}
|
||||||
targets = append(targets, tag[1])
|
targets = append(targets, tag[1])
|
||||||
@ -127,7 +127,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
|
|||||||
|
|
||||||
targets := make([]string, len(tags))
|
targets := make([]string, len(tags))
|
||||||
for i, tag := range tags {
|
for i, tag := range tags {
|
||||||
if nostr.IsValidPublicKeyHex(tag[1]) {
|
if nostr.IsValid32ByteHex(tag[1]) {
|
||||||
targets[i] = tag[1]
|
targets[i] = tag[1]
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("invalid event id hex")
|
return nil, fmt.Errorf("invalid event id hex")
|
||||||
|
@ -81,7 +81,7 @@ func (p *DynamicSigner) HandleRequest(event *nostr.Event) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
targetUser := event.Tags.GetFirst([]string{"p", ""})
|
targetUser := event.Tags.GetFirst([]string{"p", ""})
|
||||||
if targetUser == nil || !nostr.IsValidPublicKeyHex((*targetUser)[1]) {
|
if targetUser == nil || !nostr.IsValid32ByteHex((*targetUser)[1]) {
|
||||||
return req, resp, eventResponse, false, fmt.Errorf("invalid \"p\" tag")
|
return req, resp, eventResponse, false, fmt.Errorf("invalid \"p\" tag")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ func (p *DynamicSigner) HandleRequest(event *nostr.Event) (
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
thirdPartyPubkey := req.Params[0]
|
thirdPartyPubkey := req.Params[0]
|
||||||
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
|
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||||
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
|
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ func (p *DynamicSigner) HandleRequest(event *nostr.Event) (
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
thirdPartyPubkey := req.Params[0]
|
thirdPartyPubkey := req.Params[0]
|
||||||
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
|
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||||
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
|
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ func (p *StaticKeySigner) HandleRequest(event *nostr.Event) (
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
thirdPartyPubkey := req.Params[0]
|
thirdPartyPubkey := req.Params[0]
|
||||||
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
|
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||||
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
|
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ func (p *StaticKeySigner) HandleRequest(event *nostr.Event) (
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
thirdPartyPubkey := req.Params[0]
|
thirdPartyPubkey := req.Params[0]
|
||||||
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
|
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||||
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
|
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ func ParseCalendarEvent(event nostr.Event) CalendarEvent {
|
|||||||
case "g":
|
case "g":
|
||||||
calev.Geohashes = append(calev.Geohashes, tag[1])
|
calev.Geohashes = append(calev.Geohashes, tag[1])
|
||||||
case "p":
|
case "p":
|
||||||
if nostr.IsValidPublicKeyHex(tag[1]) {
|
if nostr.IsValid32ByteHex(tag[1]) {
|
||||||
part := Participant{
|
part := Participant{
|
||||||
PubKey: tag[1],
|
PubKey: tag[1],
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ func ParseLiveEvent(event nostr.Event) LiveEvent {
|
|||||||
case "recording":
|
case "recording":
|
||||||
liev.Recording = append(liev.Recording, tag[1])
|
liev.Recording = append(liev.Recording, tag[1])
|
||||||
case "p":
|
case "p":
|
||||||
if nostr.IsValidPublicKeyHex(tag[1]) {
|
if nostr.IsValid32ByteHex(tag[1]) {
|
||||||
part := Participant{
|
part := Participant{
|
||||||
PubKey: tag[1],
|
PubKey: tag[1],
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user