mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-10-29 17:16:31 +00:00
fetch mutelist by author pubkey
This commit is contained in:
parent
3d88938b7e
commit
108142b801
@ -11,6 +11,6 @@ permanent_blacklist_pubkeys:
|
|||||||
- db0c9b8acd6101adb9b281c5321f98f6eebb33c5719d230ed1870997538a9765
|
- db0c9b8acd6101adb9b281c5321f98f6eebb33c5719d230ed1870997538a9765
|
||||||
permanent_blacklist_npubs:
|
permanent_blacklist_npubs:
|
||||||
- npub1x0r5gflnk2mn6h3c70nvnywpy2j46gzqwg6k7uw6fxswyz0md9qqnhshtn
|
- npub1x0r5gflnk2mn6h3c70nvnywpy2j46gzqwg6k7uw6fxswyz0md9qqnhshtn
|
||||||
mute_list_event_ids:
|
mutelist_authors:
|
||||||
# - 76be64157af3e00cf50fae5fda63170cd4636065adf34960a4bec84a2022610b
|
- 3fe0ab6cbdb7ee27148202249e3fb3b89423c6f6cda6ef43ea5057c3d93088e4
|
||||||
# mutelist Event MUST be stored in this relay for it to be retrieved.
|
# mutelist Event MUST be stored in this relay for it to be retrieved.
|
||||||
|
@ -205,7 +205,7 @@ func saveBlacklistConfig(blacklistConfig types.BlacklistConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchPubkeysFromLocalMuteList sends a REQ to the local relay for mute list events.
|
// 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 wg sync.WaitGroup
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
var allPubkeys []string
|
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.
|
// Create the REQ message to fetch the mute list events by IDs.
|
||||||
req := []interface{}{"REQ", subscriptionID, map[string]interface{}{
|
req := []interface{}{"REQ", subscriptionID, map[string]interface{}{
|
||||||
"ids": muteListEventIDs,
|
"authors": muteListAuthors,
|
||||||
"kinds": []int{10000}, // Mute list events kind.
|
"kinds": []int{10000}, // Mute list events kind.
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -8,5 +8,5 @@ type BlacklistConfig struct {
|
|||||||
TempBanDuration int `yaml:"temp_ban_duration"`
|
TempBanDuration int `yaml:"temp_ban_duration"`
|
||||||
PermanentBlacklistPubkeys []string `yaml:"permanent_blacklist_pubkeys"`
|
PermanentBlacklistPubkeys []string `yaml:"permanent_blacklist_pubkeys"`
|
||||||
PermanentBlacklistNpubs []string `yaml:"permanent_blacklist_npubs"`
|
PermanentBlacklistNpubs []string `yaml:"permanent_blacklist_npubs"`
|
||||||
MuteListEventIDs []string `yaml:"mute_list_event_ids"`
|
MuteListAuthors []string `yaml:"mutelist_authors"`
|
||||||
}
|
}
|
@ -111,9 +111,9 @@ if blacklistCfg == nil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only proceed if there are mutelist event IDs specified
|
// 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)
|
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 {
|
if err != nil {
|
||||||
fmt.Println("Error fetching pubkeys from mutelist:", err)
|
fmt.Println("Error fetching pubkeys from mutelist:", err)
|
||||||
response.SendNotice(ws, "", "Error fetching pubkeys from mutelist")
|
response.SendNotice(ws, "", "Error fetching pubkeys from mutelist")
|
||||||
|
Loading…
Reference in New Issue
Block a user