Skip to content

Commit

Permalink
fix error of pubkey check falses
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsugu committed Nov 3, 2024
1 parent ca00814 commit 9e7e91b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
4 changes: 3 additions & 1 deletion emojiReaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ func emojiReaction(args []string, cc confClass) error {
case 3: // public_key
public_key = args[i]
if 0 < len(public_key) && is64HexString(public_key) == false {
if pref, tmpPubkey, err := toHex(public_key); err != nil || pref != "npub" {
if pref, tmpPubkey, err := toHex(public_key); err != nil {
return err
} else if pref != "npub" {
return errors.New(fmt.Sprintf("Invalid Pubkey %v", public_key))
} else {
public_key = tmpPubkey.(string)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.2

require (
github.com/mattn/go-jsonpointer v0.0.1
github.com/nbd-wtf/go-nostr v0.41.0
github.com/nbd-wtf/go-nostr v0.42.0
github.com/yosuke-furukawa/json5 v0.1.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-jsonpointer v0.0.1 h1:j5m5P9BdP4B/zn6J7oH3KIQSOa2OHmcNAKEozUW7wuE=
github.com/mattn/go-jsonpointer v0.0.1/go.mod h1:1s8vx7JSjlgVRF+LW16MPpWSRZAxyrc1/FYzOonxeao=
github.com/nbd-wtf/go-nostr v0.41.0 h1:NNvFO3zEIgA8EQMIhIMtUUTNSce1eVCXbzydpCw8qpM=
github.com/nbd-wtf/go-nostr v0.41.0/go.mod h1:FBa4FBJO7NuANvkeKSlrf0BIyxGufmrUbuelr6Q4Ick=
github.com/nbd-wtf/go-nostr v0.42.0 h1:EofWfXEhKic9AYVf4RHuXZr+kKUZE2jVyJtJByNe1rE=
github.com/nbd-wtf/go-nostr v0.42.0/go.mod h1:FBa4FBJO7NuANvkeKSlrf0BIyxGufmrUbuelr6Q4Ick=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
2 changes: 1 addition & 1 deletion publishMessageTo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
//"log"
// "log"
)

/*
Expand Down
44 changes: 31 additions & 13 deletions publishRaw.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ func publishRaw(args []string, cc confClass) error {
// calling Sign sets the event ID field and the event Sig field
ev.Sign(sk)

/*
if 0 < len(strReason) {
setContentWarning(strReason, &tgs)
}
if 0 < len(strPerson) {
setPerson(strPerson, &tgs)
}
*/

// publish the event to two relays
ctx := context.Background()
for _, url := range rl {
Expand All @@ -110,7 +100,7 @@ func publishRaw(args []string, cc confClass) error {
// }}}

/*
mkEvent {{{
mkEvent
*/
func mkEvent(pJson interface{}, cc confClass) (nostr.Event, error) {
var ev nostr.Event
Expand Down Expand Up @@ -264,11 +254,11 @@ func checkTags(kind int, tgs nostr.Tags) error {
}

var chkTblMap = map[int][]string{
1: {"content-warning", "client", "e", "emoji", "p", "q", "r", "t"},
1: {"content-warning", "client", "e", "emoji", "expiration", "p", "q", "r", "t"},
6: {"e", "p"},
10000: {"e", "p", "t", "word"},
10001: {"e"},
30315: {"d", "expiration", "r"},
30315: {"d", "emoji", "expiration", "r"},
}

func GetChkTblMap() map[int][]string {
Expand Down Expand Up @@ -322,3 +312,31 @@ func hasPrefixInTags(tgs nostr.Tags) bool {
}

// }}}

/*
*/
var modifyBech32KindTblMap = map[int][]string{
1: {"e", "p", "q"},
6: {"e", "p"},
10000: {"e", "p"},
10001: {"e"},
}
var modifyBech32TagsTblMap = map[string][]int{
"e": {1, 4}, // 1:event_id (note_id), 4:pubkey
"p": {1}, // 1:pubkey
"q": {1, 3}, // 1:event_id (note_id), 3:pubkey
}

// }}}

/*
Error check function table {{{
IMPLEMENTED IN A FUTURE MAJOR VERSION
*/
var defChkTblMap = map[string]map[int]string{
"content-warning": {1: "checkSeckey"},
"client": {1: "checkEmpty", 2: "noncheck", 3: "noncheck"},
"e": {1: "checkEventId", 2: "noncheck", 3: "checkMarker", 4: "checkPubkey"},
}

// }}}

0 comments on commit 9e7e91b

Please sign in to comment.