mirror of
https://github.com/Xevion/scla-unsubscribe.git
synced 2025-12-16 10:13:13 -06:00
Setup WaitGroups for email unsubscribing
This commit is contained in:
20
main.go
20
main.go
@@ -2,11 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
|
|
||||||
badger "github.com/dgraph-io/badger/v4"
|
badger "github.com/dgraph-io/badger/v4"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
@@ -169,15 +169,27 @@ func main() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
// Process each email
|
// Process each email
|
||||||
for email := range entries {
|
for email := range entries {
|
||||||
log.Info().Str("email", email).Msg("Unsubscribing Email")
|
log.Info().Str("email", email).Msg("Unsubscribing Email")
|
||||||
go Unsubscribe(email)
|
wg.Add(1)
|
||||||
|
go func(email string) {
|
||||||
|
defer wg.Done()
|
||||||
|
Unsubscribe(email)
|
||||||
|
}(email)
|
||||||
|
|
||||||
// 1/2 chance to unsubscribe fake email
|
// 1/2 chance to unsubscribe fake email
|
||||||
if rand.Intn(2) == 0 {
|
if RandBool() {
|
||||||
log.Info().Str("email", email).Msg("Unsubscribing Fake Email")
|
log.Info().Str("email", email).Msg("Unsubscribing Fake Email")
|
||||||
go Unsubscribe(email)
|
wg.Add(1)
|
||||||
|
go func(email string) {
|
||||||
|
defer wg.Done()
|
||||||
|
go Unsubscribe(FakeEmail())
|
||||||
|
}(email)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user