diff --git a/event.go b/event.go index cce165e..2dd9a97 100644 --- a/event.go +++ b/event.go @@ -16,9 +16,6 @@ type Event struct { Tags Tags Content string Sig string - - // anything here will be mashed together with the main event object when serializing - extra map[string]any } // Event Stringer interface, just returns the raw JSON as a string. diff --git a/event_easyjson.go b/event_easyjson.go index 435583c..8888b9c 100644 --- a/event_easyjson.go +++ b/event_easyjson.go @@ -22,7 +22,6 @@ func easyjsonF642ad3eDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Event) in.Skip() return } - out.extra = make(map[string]any) in.Delim('{') for !in.IsDelim('}') { key := in.UnsafeFieldName(true) @@ -85,8 +84,6 @@ func easyjsonF642ad3eDecodeGithubComNbdWtfGoNostr(in *jlexer.Lexer, out *Event) out.Content = in.String() case "sig": out.Sig = in.String() - default: - out.extra[key] = in.Interface() } in.WantComma() } @@ -155,12 +152,6 @@ func easyjsonF642ad3eEncodeGithubComNbdWtfGoNostr(out *jwriter.Writer, in Event) out.String(in.Sig) } } - { - for key, value := range in.extra { - out.RawString(",\"" + key + "\":") - out.Raw(json.Marshal(value)) - } - } out.RawByte('}') } diff --git a/event_extra.go b/event_extra.go deleted file mode 100644 index 46263b3..0000000 --- a/event_extra.go +++ /dev/null @@ -1,68 +0,0 @@ -package nostr - -// Deprecated: this was never a good idea, stop using. -func (evt *Event) SetExtra(key string, value any) { - if evt.extra == nil { - evt.extra = make(map[string]any) - } - evt.extra[key] = value -} - -// Deprecated: this was never a good idea, stop using. -func (evt *Event) RemoveExtra(key string) { - if evt.extra == nil { - return - } - delete(evt.extra, key) -} - -// Deprecated: this was never a good idea, stop using. -func (evt Event) GetExtra(key string) any { - ival, _ := evt.extra[key] - return ival -} - -// Deprecated: this was never a good idea, stop using. -func (evt Event) GetExtraString(key string) string { - ival, ok := evt.extra[key] - if !ok { - return "" - } - val, ok := ival.(string) - if !ok { - return "" - } - return val -} - -// Deprecated: this was never a good idea, stop using. -func (evt Event) GetExtraNumber(key string) float64 { - ival, ok := evt.extra[key] - if !ok { - return 0 - } - - switch val := ival.(type) { - case float64: - return val - case int: - return float64(val) - case int64: - return float64(val) - } - - return 0 -} - -// Deprecated: this was never a good idea, stop using. -func (evt Event) GetExtraBoolean(key string) bool { - ival, ok := evt.extra[key] - if !ok { - return false - } - val, ok := ival.(bool) - if !ok { - return false - } - return val -} diff --git a/event_test.go b/event_test.go index c05e534..e5c9c37 100644 --- a/event_test.go +++ b/event_test.go @@ -12,8 +12,8 @@ import ( func TestEventParsingAndVerifying(t *testing.T) { rawEvents := []string{ `{"kind":1,"id":"dc90c95f09947507c1044e8f48bcf6350aa6bff1507dd4acfc755b9239b5c962","pubkey":"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d","created_at":1644271588,"tags":[],"content":"now that https://blueskyweb.org/blog/2-7-2022-overview was announced we can stop working on nostr?","sig":"230e9d8f0ddaf7eb70b5f7741ccfa37e87a455c9a469282e3464e2052d3192cd63a167e196e381ef9d7e69e9ea43af2443b839974dc85d8aaab9efe1d9296524"}`, - `{"kind":1,"id":"dc90c95f09947507c1044e8f48bcf6350aa6bff1507dd4acfc755b9239b5c962","pubkey":"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d","created_at":1644271588,"tags":[],"content":"now that https://blueskyweb.org/blog/2-7-2022-overview was announced we can stop working on nostr?","sig":"230e9d8f0ddaf7eb70b5f7741ccfa37e87a455c9a469282e3464e2052d3192cd63a167e196e381ef9d7e69e9ea43af2443b839974dc85d8aaab9efe1d9296524","extrakey":55}`, - `{"kind":1,"id":"dc90c95f09947507c1044e8f48bcf6350aa6bff1507dd4acfc755b9239b5c962","pubkey":"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d","created_at":1644271588,"tags":[],"content":"now that https://blueskyweb.org/blog/2-7-2022-overview was announced we can stop working on nostr?","sig":"230e9d8f0ddaf7eb70b5f7741ccfa37e87a455c9a469282e3464e2052d3192cd63a167e196e381ef9d7e69e9ea43af2443b839974dc85d8aaab9efe1d9296524","extrakey":"aaa"}`, + `{"kind":1,"id":"dc90c95f09947507c1044e8f48bcf6350aa6bff1507dd4acfc755b9239b5c962","pubkey":"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d","created_at":1644271588,"tags":[],"content":"now that https://blueskyweb.org/blog/2-7-2022-overview was announced we can stop working on nostr?","sig":"230e9d8f0ddaf7eb70b5f7741ccfa37e87a455c9a469282e3464e2052d3192cd63a167e196e381ef9d7e69e9ea43af2443b839974dc85d8aaab9efe1d9296524"}`, + `{"kind":1,"id":"dc90c95f09947507c1044e8f48bcf6350aa6bff1507dd4acfc755b9239b5c962","pubkey":"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d","created_at":1644271588,"tags":[],"content":"now that https://blueskyweb.org/blog/2-7-2022-overview was announced we can stop working on nostr?","sig":"230e9d8f0ddaf7eb70b5f7741ccfa37e87a455c9a469282e3464e2052d3192cd63a167e196e381ef9d7e69e9ea43af2443b839974dc85d8aaab9efe1d9296524"}`, `{"kind":3,"id":"9e662bdd7d8abc40b5b15ee1ff5e9320efc87e9274d8d440c58e6eed2dddfbe2","pubkey":"373ebe3d45ec91977296a178d9f19f326c70631d2a1b0bbba5c5ecc2eb53b9e7","created_at":1644844224,"tags":[["p","3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"],["p","75fc5ac2487363293bd27fb0d14fb966477d0f1dbc6361d37806a6a740eda91e"],["p","46d0dfd3a724a302ca9175163bdf788f3606b3fd1bb12d5fe055d1e418cb60ea"]],"content":"{\"wss://nostr-pub.wellorder.net\":{\"read\":true,\"write\":true},\"wss://nostr.bitcoiner.social\":{\"read\":false,\"write\":true},\"wss://expensive-relay.fiatjaf.com\":{\"read\":true,\"write\":true},\"wss://relayer.fiatjaf.com\":{\"read\":true,\"write\":true},\"wss://relay.bitid.nz\":{\"read\":true,\"write\":true},\"wss://nostr.rocks\":{\"read\":true,\"write\":true}}","sig":"811355d3484d375df47581cb5d66bed05002c2978894098304f20b595e571b7e01b2efd906c5650080ffe49cf1c62b36715698e9d88b9e8be43029a2f3fa66be"}`, }