fetch mutelist by author pubkey

This commit is contained in:
0ceanSlim 2024-10-18 07:52:48 -04:00
parent 3d88938b7e
commit 108142b801
4 changed files with 7 additions and 7 deletions

View File

@ -11,6 +11,6 @@ permanent_blacklist_pubkeys:
- db0c9b8acd6101adb9b281c5321f98f6eebb33c5719d230ed1870997538a9765
permanent_blacklist_npubs:
- npub1x0r5gflnk2mn6h3c70nvnywpy2j46gzqwg6k7uw6fxswyz0md9qqnhshtn
mute_list_event_ids:
# - 76be64157af3e00cf50fae5fda63170cd4636065adf34960a4bec84a2022610b
mutelist_authors:
- 3fe0ab6cbdb7ee27148202249e3fb3b89423c6f6cda6ef43ea5057c3d93088e4
# mutelist Event MUST be stored in this relay for it to be retrieved.

View File

@ -205,7 +205,7 @@ func saveBlacklistConfig(blacklistConfig types.BlacklistConfig) error {
}
// FetchPubkeysFromLocalMuteList sends a REQ to the local relay for mute list events.
func FetchPubkeysFromLocalMuteList(localRelayURL string, muteListEventIDs []string) ([]string, error) {
func FetchPubkeysFromLocalMuteList(localRelayURL string, muteListAuthors []string) ([]string, error) {
var wg sync.WaitGroup
var mu sync.Mutex
var allPubkeys []string
@ -226,7 +226,7 @@ func FetchPubkeysFromLocalMuteList(localRelayURL string, muteListEventIDs []stri
// Create the REQ message to fetch the mute list events by IDs.
req := []interface{}{"REQ", subscriptionID, map[string]interface{}{
"ids": muteListEventIDs,
"authors": muteListAuthors,
"kinds": []int{10000}, // Mute list events kind.
}}

View File

@ -8,5 +8,5 @@ type BlacklistConfig struct {
TempBanDuration int `yaml:"temp_ban_duration"`
PermanentBlacklistPubkeys []string `yaml:"permanent_blacklist_pubkeys"`
PermanentBlacklistNpubs []string `yaml:"permanent_blacklist_npubs"`
MuteListEventIDs []string `yaml:"mute_list_event_ids"`
MuteListAuthors []string `yaml:"mutelist_authors"`
}

View File

@ -111,9 +111,9 @@ if blacklistCfg == nil {
}
// Only proceed if there are mutelist event IDs specified
if len(blacklistCfg.MuteListEventIDs) > 0 {
if len(blacklistCfg.MuteListAuthors) > 0 {
localRelayURL := fmt.Sprintf("ws://localhost%s", cfg.Server.Port)
mutelistedPubkeys, err := config.FetchPubkeysFromLocalMuteList(localRelayURL, blacklistCfg.MuteListEventIDs)
mutelistedPubkeys, err := config.FetchPubkeysFromLocalMuteList(localRelayURL, blacklistCfg.MuteListAuthors)
if err != nil {
fmt.Println("Error fetching pubkeys from mutelist:", err)
response.SendNotice(ws, "", "Error fetching pubkeys from mutelist")