Compare commits

..

No commits in common. "master" and "v0.1.15" have entirely different histories.

3 changed files with 1 additions and 35 deletions

View File

@ -25,6 +25,3 @@ ARCHIVE_REACTIONS="FALSE" # optional, reactions take up a lot of space and compu
# optional, certain note kinds older than this many days will be deleted # optional, certain note kinds older than this many days will be deleted
MAX_AGE_DAYS=365 MAX_AGE_DAYS=365
# comma delimited list of pubkeys who follow bots and ruin the WoT
IGNORE_FOLLOWS_LIST=""

View File

@ -64,7 +64,6 @@ REFRESH_INTERVAL_HOURS=24 # interval in hours to refresh the web of trust
MINIMUM_FOLLOWERS=3 #how many followers before they're allowed in the WoT MINIMUM_FOLLOWERS=3 #how many followers before they're allowed in the WoT
ARCHIVAL_SYNC="FALSE" # set to TRUE to archive every note from every person in the WoT (not recommended) ARCHIVAL_SYNC="FALSE" # set to TRUE to archive every note from every person in the WoT (not recommended)
ARCHIVE_REACTIONS="FALSE" # set to TRUE to archive every reaction from every person in the WoT (not recommended) ARCHIVE_REACTIONS="FALSE" # set to TRUE to archive every reaction from every person in the WoT (not recommended)
IGNORE_FOLLOWS_LIST="" # comma separated list of pubkeys who follow too many bots and ruin the WoT
``` ```
### 4. Build the project ### 4. Build the project

30
main.go
View File

@ -9,7 +9,6 @@ import (
"net/http" "net/http"
"os" "os"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/fiatjaf/eventstore" "github.com/fiatjaf/eventstore"
@ -39,7 +38,6 @@ type Config struct {
RelayIcon string RelayIcon string
MaxAgeDays int MaxAgeDays int
ArchiveReactions bool ArchiveReactions bool
IgnoredPubkeys []string
} }
var pool *nostr.SimplePool var pool *nostr.SimplePool
@ -211,11 +209,6 @@ func LoadConfig() Config {
os.Setenv("ARCHIVE_REACTIONS", "FALSE") os.Setenv("ARCHIVE_REACTIONS", "FALSE")
} }
ignoredPubkeys := []string{}
if ignoreList := os.Getenv("IGNORE_FOLLOWS_LIST"); ignoreList != "" {
ignoredPubkeys = splitAndTrim(ignoreList)
}
minimumFollowers, _ := strconv.Atoi(os.Getenv("MINIMUM_FOLLOWERS")) minimumFollowers, _ := strconv.Atoi(os.Getenv("MINIMUM_FOLLOWERS"))
maxAgeDays, _ := strconv.Atoi(os.Getenv("MAX_AGE_DAYS")) maxAgeDays, _ := strconv.Atoi(os.Getenv("MAX_AGE_DAYS"))
@ -234,7 +227,6 @@ func LoadConfig() Config {
ArchivalSync: getEnv("ARCHIVAL_SYNC") == "TRUE", ArchivalSync: getEnv("ARCHIVAL_SYNC") == "TRUE",
MaxAgeDays: maxAgeDays, MaxAgeDays: maxAgeDays,
ArchiveReactions: getEnv("ARCHIVE_REACTIONS") == "TRUE", ArchiveReactions: getEnv("ARCHIVE_REACTIONS") == "TRUE",
IgnoredPubkeys: ignoredPubkeys,
} }
return config return config
@ -298,11 +290,6 @@ func refreshTrustNetwork(ctx context.Context, relay *khatru.Relay) {
log.Println("🔍 fetching owner's follows") log.Println("🔍 fetching owner's follows")
for ev := range pool.SubManyEose(timeoutCtx, seedRelays, filters) { for ev := range pool.SubManyEose(timeoutCtx, seedRelays, filters) {
for _, contact := range ev.Event.Tags.GetAll([]string{"p"}) { for _, contact := range ev.Event.Tags.GetAll([]string{"p"}) {
pubkey := contact[1]
if isIgnored(pubkey, config.IgnoredPubkeys) {
fmt.Println("ignoring follows from pubkey: ", pubkey)
continue
}
pubkeyFollowerCount[contact[1]]++ // Increment follower count for the pubkey pubkeyFollowerCount[contact[1]]++ // Increment follower count for the pubkey
appendOneHopNetwork(contact[1]) appendOneHopNetwork(contact[1])
} }
@ -536,20 +523,3 @@ func getDB() badger.BadgerBackend {
Path: getEnv("DB_PATH"), Path: getEnv("DB_PATH"),
} }
} }
func splitAndTrim(input string) []string {
items := strings.Split(input, ",")
for i, item := range items {
items[i] = strings.TrimSpace(item)
}
return items
}
func isIgnored(pubkey string, ignoredPubkeys []string) bool {
for _, ignored := range ignoredPubkeys {
if pubkey == ignored {
return true
}
}
return false
}