mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-07-12 21:42:28 +02:00
fix(rss): fixing event creation date type
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
*.env
|
||||
rss-bridge
|
@ -11,9 +11,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
strip "github.com/grokify/html-strip-tags-go"
|
||||
"github.com/mmcdole/gofeed"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/rif/cache2go"
|
||||
)
|
||||
|
||||
@ -108,7 +108,7 @@ func feedToSetMetadata(pubkey string, feed *gofeed.Feed) nostr.Event {
|
||||
|
||||
evt := nostr.Event{
|
||||
PubKey: pubkey,
|
||||
CreatedAt: createdAt,
|
||||
CreatedAt: nostr.Timestamp(createdAt.Unix()),
|
||||
Kind: nostr.KindSetMetadata,
|
||||
Tags: nostr.Tags{},
|
||||
Content: string(content),
|
||||
@ -139,7 +139,7 @@ func itemToTextNote(pubkey string, item *gofeed.Item) nostr.Event {
|
||||
|
||||
evt := nostr.Event{
|
||||
PubKey: pubkey,
|
||||
CreatedAt: createdAt,
|
||||
CreatedAt: nostr.Timestamp(createdAt.Unix()),
|
||||
Kind: nostr.KindTextNote,
|
||||
Tags: nostr.Tags{},
|
||||
Content: content,
|
||||
|
@ -75,7 +75,7 @@ func (relay *Relay) Init() error {
|
||||
for _, item := range feed.Items {
|
||||
evt := itemToTextNote(pubkey, item)
|
||||
last, ok := relay.lastEmitted.Load(entity.URL)
|
||||
if !ok || time.Unix(last.(int64), 0).Before(evt.CreatedAt) {
|
||||
if !ok || time.Unix(last.(int64), 0).Before(evt.CreatedAt.Time()) {
|
||||
evt.Sign(entity.PrivateKey)
|
||||
relay.updates <- evt
|
||||
relay.lastEmitted.Store(entity.URL, last)
|
||||
@ -137,10 +137,10 @@ func (b store) QueryEvents(filter *nostr.Filter) ([]nostr.Event, error) {
|
||||
if filter.Kinds == nil || slices.Contains(filter.Kinds, nostr.KindSetMetadata) {
|
||||
evt := feedToSetMetadata(pubkey, feed)
|
||||
|
||||
if filter.Since != nil && evt.CreatedAt.Before(*filter.Since) {
|
||||
if filter.Since != nil && evt.CreatedAt.Time().Before(filter.Since.Time()) {
|
||||
continue
|
||||
}
|
||||
if filter.Until != nil && evt.CreatedAt.After(*filter.Until) {
|
||||
if filter.Until != nil && evt.CreatedAt.Time().After(filter.Until.Time()) {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -153,17 +153,17 @@ func (b store) QueryEvents(filter *nostr.Filter) ([]nostr.Event, error) {
|
||||
for _, item := range feed.Items {
|
||||
evt := itemToTextNote(pubkey, item)
|
||||
|
||||
if filter.Since != nil && evt.CreatedAt.Before(*filter.Since) {
|
||||
if filter.Since != nil && evt.CreatedAt.Time().Before(filter.Since.Time()) {
|
||||
continue
|
||||
}
|
||||
if filter.Until != nil && evt.CreatedAt.After(*filter.Until) {
|
||||
if filter.Until != nil && evt.CreatedAt.Time().After(filter.Until.Time()) {
|
||||
continue
|
||||
}
|
||||
|
||||
evt.Sign(entity.PrivateKey)
|
||||
|
||||
if evt.CreatedAt.After(time.Unix(int64(last), 0)) {
|
||||
last = uint32(evt.CreatedAt.Unix())
|
||||
if evt.CreatedAt.Time().After(time.Unix(int64(last), 0)) {
|
||||
last = uint32(evt.CreatedAt.Time().Unix())
|
||||
}
|
||||
|
||||
evts = append(evts, evt)
|
||||
|
Reference in New Issue
Block a user