mirror of
https://github.com/bitvora/wot-relay.git
synced 2025-04-22 16:51:28 +00:00
Merge pull request #64 from bitvora/dev-disableReactions
disable reaction archiving, use map to allow posting
This commit is contained in:
commit
e76839077f
@ -21,6 +21,7 @@ MINIMUM_FOLLOWERS=5
|
||||
|
||||
# archive all notes from everyone in your WoT from other relays
|
||||
ARCHIVAL_SYNC="FALSE"
|
||||
ARCHIVE_REACTIONS="FALSE" # optional, reactions take up a lot of space and compute
|
||||
|
||||
# optional, certain note kinds older than this many days will be deleted
|
||||
MAX_AGE_DAYS=365
|
@ -22,7 +22,6 @@ Don't want to run the relay, just want to connect to some? Here are some availab
|
||||
- [wss://satsage.xyz](https://satsage.xyz)
|
||||
- [wss://wons.calva.dev](https://wons.calva.dev)
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- **Go**: Ensure you have Go installed on your system. You can download it from [here](https://golang.org/dl/).
|
||||
@ -61,6 +60,7 @@ STATIC_PATH="/home/ubuntu/wot-relay/templates/static" # path to the static folde
|
||||
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
|
||||
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)
|
||||
```
|
||||
|
||||
### 4. Build the project
|
||||
@ -73,7 +73,7 @@ go build -ldflags "-X main.version=$(git describe --tags --always)"
|
||||
|
||||
### 5. Create a Systemd Service (optional)
|
||||
|
||||
To have the relay run as a service, create a systemd unit file. Here's an example:
|
||||
To have the relay run as a service, create a systemd unit file. Make sure to limit the memory usage to less than your system's total memory to prevent the relay from crashing the system.
|
||||
|
||||
1. Create the file:
|
||||
|
||||
@ -89,9 +89,10 @@ Description=WOT Relay Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/home/ubuntu/wot-relay/wot-relay #change this to your path
|
||||
WorkingDirectory=/home/ubuntu/wot-relay #change this to your path
|
||||
ExecStart=/home/ubuntu/wot-relay/wot-relay
|
||||
WorkingDirectory=/home/ubuntu/wot-relay
|
||||
Restart=always
|
||||
MemoryLimit=2G
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
63
main.go
63
main.go
@ -36,6 +36,7 @@ type Config struct {
|
||||
RelayContact string
|
||||
RelayIcon string
|
||||
MaxAgeDays int
|
||||
ArchiveReactions bool
|
||||
}
|
||||
|
||||
var pool *nostr.SimplePool
|
||||
@ -112,12 +113,10 @@ func main() {
|
||||
relay.QueryEvents = append(relay.QueryEvents, db.QueryEvents)
|
||||
relay.DeleteEvent = append(relay.DeleteEvent, db.DeleteEvent)
|
||||
relay.RejectEvent = append(relay.RejectEvent, func(ctx context.Context, event *nostr.Event) (bool, string) {
|
||||
for _, pk := range trustNetwork {
|
||||
if pk == event.PubKey {
|
||||
return false, ""
|
||||
}
|
||||
if !trustNetworkMap[event.PubKey] {
|
||||
return true, "you are not in the web of trust"
|
||||
}
|
||||
return true, "you are not in the web of trust"
|
||||
return false, ""
|
||||
})
|
||||
|
||||
seedRelays = []string{
|
||||
@ -201,6 +200,10 @@ func LoadConfig() Config {
|
||||
os.Setenv("MAX_AGE_DAYS", "0")
|
||||
}
|
||||
|
||||
if os.Getenv("ARCHIVE_REACTIONS") == "" {
|
||||
os.Setenv("ARCHIVE_REACTIONS", "FALSE")
|
||||
}
|
||||
|
||||
minimumFollowers, _ := strconv.Atoi(os.Getenv("MINIMUM_FOLLOWERS"))
|
||||
maxAgeDays, _ := strconv.Atoi(os.Getenv("MAX_AGE_DAYS"))
|
||||
|
||||
@ -218,6 +221,7 @@ func LoadConfig() Config {
|
||||
MinimumFollowers: minimumFollowers,
|
||||
ArchivalSync: getEnv("ARCHIVAL_SYNC") == "TRUE",
|
||||
MaxAgeDays: maxAgeDays,
|
||||
ArchiveReactions: getEnv("ARCHIVE_REACTIONS") == "TRUE",
|
||||
}
|
||||
|
||||
return config
|
||||
@ -377,21 +381,40 @@ func archiveTrustedNotes(ctx context.Context, relay *khatru.Relay) {
|
||||
if config.ArchivalSync {
|
||||
go refreshProfiles(ctx)
|
||||
|
||||
filters := []nostr.Filter{{
|
||||
Kinds: []int{
|
||||
nostr.KindArticle,
|
||||
nostr.KindDeletion,
|
||||
nostr.KindContactList,
|
||||
nostr.KindEncryptedDirectMessage,
|
||||
nostr.KindMuteList,
|
||||
nostr.KindReaction,
|
||||
nostr.KindRelayListMetadata,
|
||||
nostr.KindRepost,
|
||||
nostr.KindZapRequest,
|
||||
nostr.KindZap,
|
||||
nostr.KindTextNote,
|
||||
},
|
||||
}}
|
||||
var filters []nostr.Filter
|
||||
if config.ArchiveReactions {
|
||||
|
||||
filters = []nostr.Filter{{
|
||||
Kinds: []int{
|
||||
nostr.KindArticle,
|
||||
nostr.KindDeletion,
|
||||
nostr.KindContactList,
|
||||
nostr.KindEncryptedDirectMessage,
|
||||
nostr.KindMuteList,
|
||||
nostr.KindReaction,
|
||||
nostr.KindRelayListMetadata,
|
||||
nostr.KindRepost,
|
||||
nostr.KindZapRequest,
|
||||
nostr.KindZap,
|
||||
nostr.KindTextNote,
|
||||
},
|
||||
}}
|
||||
} else {
|
||||
filters = []nostr.Filter{{
|
||||
Kinds: []int{
|
||||
nostr.KindArticle,
|
||||
nostr.KindDeletion,
|
||||
nostr.KindContactList,
|
||||
nostr.KindEncryptedDirectMessage,
|
||||
nostr.KindMuteList,
|
||||
nostr.KindRelayListMetadata,
|
||||
nostr.KindRepost,
|
||||
nostr.KindZapRequest,
|
||||
nostr.KindZap,
|
||||
nostr.KindTextNote,
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
log.Println("📦 archiving trusted notes...")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user