@@ 19,6 19,7 @@ import (
"regexp"
"strconv"
"strings"
+ "time"
"git.sr.ht/~emersion/gqlclient"
"github.com/99designs/gqlgen/graphql"
@@ 614,10 615,22 @@ func GetDisabledElementsByOrg(ctx context.Context, org *models.Organization) (*C
}
func ArchiveURLSnapshot(ctx context.Context, orgLink *models.OrgLink) error {
- resp, err := http.Get(fmt.Sprintf("https://web.archive.org/save/%s", orgLink.URL))
+ httpClient := &http.Client{
+ Timeout: time.Duration(30) * time.Second,
+ }
+ req, err := http.NewRequest(
+ "GET",
+ fmt.Sprintf("https://web.archive.org/save/%s", orgLink.URL),
+ nil,
+ )
+ if err != nil {
+ return err
+ }
+ resp, err := httpClient.Do(req)
if err != nil {
return err
}
+
if resp.StatusCode == http.StatusOK && resp.Request.URL.String() != "" {
orgLink.ArchiveURL = resp.Request.URL.String()
return orgLink.Store(ctx)