mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-18 14:54:24 +01:00
Add npubs archive
Add more npubs
This commit is contained in:
21
utils.go
21
utils.go
@@ -1,11 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gomarkdown/markdown"
|
||||
"github.com/gomarkdown/markdown/html"
|
||||
@@ -344,3 +346,22 @@ func trimProtocol(relay string) string {
|
||||
relay = strings.TrimPrefix(relay, "ws:/") // Some browsers replace upfront '//' with '/'
|
||||
return relay
|
||||
}
|
||||
|
||||
func loadNpubsArchive(ctx context.Context) {
|
||||
fmt.Println("Refreshing the npubs archive")
|
||||
|
||||
contactsArchive := make([]string, 0, 500)
|
||||
|
||||
for _, pubkey := range trustedPubKeys {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*4)
|
||||
pubkeyContacts := contactsForPubkey(ctx, pubkey)
|
||||
contactsArchive = append(contactsArchive, pubkeyContacts...)
|
||||
cancel()
|
||||
}
|
||||
|
||||
contactsArchive = unique(contactsArchive)
|
||||
for _, contact := range contactsArchive {
|
||||
fmt.Printf("Adding contact %s\n", contact)
|
||||
cache.SetWithTTL("pa:"+contact, nil, time.Hour*24*90)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user