Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add timeout

Neeraj Gupta67e51323488e
diff --git a/server/pkg/external/listmonk/api.go b/server/pkg/external/listmonk/api.go
index fb0bb190c9..50a98ce4b5 100644
--- a/server/pkg/external/listmonk/api.go
+++ b/server/pkg/external/listmonk/api.go
@@ -10,6 +10,7 @@ import (
"net/url"
"strconv"
"strings"
+ "time"
"github.com/ente-io/stacktrace"
)
@@ -25,6 +26,8 @@ type Credentials struct {
Password string
}
+const listmonkRequestTimeout = 60 * time.Second
+
// Subscriber captures a listmonk subscriber record required by museum.
type Subscriber struct {
Email string
@@ -74,7 +77,7 @@ func GetSubscriberID(endpoint string, username string, password string, subscrib
req.SetBasicAuth(username, password)
// Sending the HTTP request
- client := &http.Client{}
+ client := &http.Client{Timeout: listmonkRequestTimeout}
resp, err := client.Do(req)
if err != nil {
return 0, stacktrace.Propagate(err, "")
@@ -131,7 +134,7 @@ func ListSubscribers(endpoint string, username string, password string, page int
}
req.SetBasicAuth(username, password)
- client := &http.Client{}
+ client := &http.Client{Timeout: listmonkRequestTimeout}
resp, err := client.Do(req)
if err != nil {
return SubscribersPage{}, stacktrace.Propagate(err, "")
@@ -260,7 +263,7 @@ func SendRequest(method string, url string, data interface{}, username string, p
return stacktrace.Propagate(err, "")
}
- client := &http.Client{}
+ client := &http.Client{Timeout: listmonkRequestTimeout}
req, err := http.NewRequest(method, url, bytes.NewBuffer(jsonData))
if err != nil {
return stacktrace.Propagate(err, "")