fixing implementation of previous commit in multiple places.

This commit is contained in:
fiatjaf
2023-11-05 14:39:02 -03:00
parent 9967d10cd6
commit e477d38e66
4 changed files with 22 additions and 12 deletions

View File

@@ -239,13 +239,21 @@ func getParentNevent(event *nostr.Event) string {
return parentNevent
}
func attachRelaysToEvent(event *nostr.Event, relays ...string) {
key := "rls:" + event.ID
func attachRelaysToEvent(eventId string, relays ...string) []string {
key := "rls:" + eventId
existingRelays := make([]string, 0, 10)
if exists := cache.GetJSON(key, &existingRelays); exists {
relays = unique(append(existingRelays, relays...))
}
cache.SetJSONWithTTL(key, relays, time.Hour*24*7)
return relays
}
func getRelaysForEvent(eventId string) []string {
key := "rls:" + eventId
relays := make([]string, 0, 10)
cache.GetJSON(key, &relays)
return relays
}
func scheduleEventExpiration(eventId string, ts time.Duration) {