update go-nostr and fix rss-bridge.

This commit is contained in:
fiatjaf
2023-01-02 14:31:28 -03:00
parent 9ba958e9a0
commit e70a5601c7
3 changed files with 8 additions and 6 deletions

2
go.mod
View File

@@ -13,7 +13,7 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/lib/pq v1.10.3
github.com/mmcdole/gofeed v1.1.3
github.com/nbd-wtf/go-nostr v0.9.0
github.com/nbd-wtf/go-nostr v0.10.0
github.com/rif/cache2go v1.0.0
github.com/rs/cors v1.7.0
github.com/stevelacy/daz v0.1.4

4
go.sum
View File

@@ -320,8 +320,8 @@ github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOA
github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM=
github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nbd-wtf/go-nostr v0.9.0 h1:6wDsgKUXOtnzHwe/RW80yBebsVNg5jbRyBCTyxlDjiw=
github.com/nbd-wtf/go-nostr v0.9.0/go.mod h1:qFFTIxh15H5GGN0WsBI/P73DteqsevnhSEW/yk8nEf4=
github.com/nbd-wtf/go-nostr v0.10.0 h1:95y0VjyplDCInPn7VD2eNvRHwTGib1LxfVKp0Fv2ZQY=
github.com/nbd-wtf/go-nostr v0.10.0/go.mod h1:qFFTIxh15H5GGN0WsBI/P73DteqsevnhSEW/yk8nEf4=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nwaples/rardecode v1.1.2 h1:Cj0yZY6T1Zx1R7AhTbyGSALm44/Mmq+BAPc4B/p/d3M=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=

View File

@@ -12,6 +12,7 @@ import (
"github.com/fiatjaf/relayer"
"github.com/kelseyhightower/envconfig"
"github.com/nbd-wtf/go-nostr"
"golang.org/x/exp/slices"
)
var relay = &Relay{
@@ -54,7 +55,7 @@ func (relay *Relay) Init() error {
log.Printf("checking for updates; %d filters active", len(filters))
for _, filter := range filters {
if filter.Kinds == nil || filter.Kinds.Contains(nostr.KindTextNote) {
if filter.Kinds == nil || slices.Contains(filter.Kinds, nostr.KindTextNote) {
for _, pubkey := range filter.Authors {
if val, closer, err := relay.db.Get([]byte(pubkey)); err == nil {
defer closer.Close()
@@ -105,6 +106,7 @@ func (b store) Init() error { return nil }
func (b store) SaveEvent(_ *nostr.Event) error {
return errors.New("blocked: we don't accept any events")
}
func (b store) DeleteEvent(_, _ string) error {
return errors.New("blocked: we can't delete any events")
}
@@ -132,7 +134,7 @@ func (b store) QueryEvents(filter *nostr.Filter) ([]nostr.Event, error) {
continue
}
if filter.Kinds == nil || filter.Kinds.Contains(nostr.KindSetMetadata) {
if filter.Kinds == nil || slices.Contains(filter.Kinds, nostr.KindSetMetadata) {
evt := feedToSetMetadata(pubkey, feed)
if filter.Since != nil && evt.CreatedAt.Before(*filter.Since) {
@@ -146,7 +148,7 @@ func (b store) QueryEvents(filter *nostr.Filter) ([]nostr.Event, error) {
evts = append(evts, evt)
}
if filter.Kinds == nil || filter.Kinds.Contains(nostr.KindTextNote) {
if filter.Kinds == nil || slices.Contains(filter.Kinds, nostr.KindTextNote) {
var last uint32 = 0
for _, item := range feed.Items {
evt := itemToTextNote(pubkey, item)