From a746c61886c37585bad463c2bdf4ec22900df7a3 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Sun, 10 Mar 2024 08:02:41 -0600 Subject: [PATCH] Adding 5 minute timeout for Web Archive request --- api/graph/generated.go | 24 ++---------------------- api/graph/schema.graphqls | 2 +- api/graph/schema.resolvers.go | 2 +- core/routes.go | 2 +- go.mod | 2 +- go.sum | 2 ++ helpers.go | 4 +++- short/routes.go | 4 ++++ 8 files changed, 15 insertions(+), 27 deletions(-) diff --git a/api/graph/generated.go b/api/graph/generated.go index 733197a..ce03fc5 100644 --- a/api/graph/generated.go +++ b/api/graph/generated.go @@ -6518,28 +6518,8 @@ func (ec *executionContext) _LinkShort_orgId(ctx context.Context, field graphql. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OrgID, nil - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.Private == nil { - return nil, errors.New("directive private is not implemented") - } - return ec.directives.Private(ctx, obj, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(int); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be int`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.OrgID, nil }) if err != nil { ec.Error(ctx, err) diff --git a/api/graph/schema.graphqls b/api/graph/schema.graphqls index b15422a..32f7ff2 100644 --- a/api/graph/schema.graphqls +++ b/api/graph/schema.graphqls @@ -168,7 +168,7 @@ type LinkShort { tags: [Tag]! userId: Int! @access(scope: SHORTS, kind: RO) domainId: Int @private - orgId: Int! @private + orgId: Int! lookupName: String! @private createdOn: Time !@private updatedOn: Time !@private diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go index 46009de..8281d27 100644 --- a/api/graph/schema.resolvers.go +++ b/api/graph/schema.resolvers.go @@ -39,7 +39,7 @@ import ( "golang.org/x/image/draw" "golang.org/x/net/idna" "netlandish.com/x/gobwebs" - oauth2 "netlandish.com/x/gobwebs-oauth2" + "netlandish.com/x/gobwebs-oauth2" gaccounts "netlandish.com/x/gobwebs/accounts" "netlandish.com/x/gobwebs/database" "netlandish.com/x/gobwebs/email" diff --git a/core/routes.go b/core/routes.go index 8bb07f7..b5ff9a1 100644 --- a/core/routes.go +++ b/core/routes.go @@ -2325,7 +2325,7 @@ func (s *Service) QRRedirect(c echo.Context) error { if links.BillingEnabled(gctx.Server.Config) && org.IsRestricted([]int{ models.BillingStatusFree, models.BillingStatusOpenSource}) { lt := localizer.GetSessionLocalizer(c) - pd := localizer.NewPageData(lt.Translate("QR Codes Powered by Link Taco!")) + pd := localizer.NewPageData(lt.Translate("QR Codes powered by Link Taco!")) pd.Data["redirected"] = lt.Translate("You will be redirected in 10 seconds.") gmap := gobwebs.Map{ "pd": pd, diff --git a/go.mod b/go.mod index 789232f..82c3dbf 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/image v0.0.0-20211028202545-6944b10bf410 golang.org/x/net v0.20.0 golang.org/x/text v0.14.0 - netlandish.com/x/gobwebs v0.0.0-20240308002929-df98b40506b0 + netlandish.com/x/gobwebs v0.0.0-20240309201308-582da32e3e94 netlandish.com/x/gobwebs-formguard v0.0.0-20231224192353-29706d23f156 netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c netlandish.com/x/gobwebs-ses-feedback v0.0.0-20231224192331-d90c2b73e55d diff --git a/go.sum b/go.sum index 839a032..26175c4 100644 --- a/go.sum +++ b/go.sum @@ -2558,6 +2558,8 @@ modernc.org/z v1.2.20/go.mod h1:zU9FiF4PbHdOTUxw+IF8j7ArBMRPsHgq10uVPt6xTzo= modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4= netlandish.com/x/gobwebs v0.0.0-20240308002929-df98b40506b0 h1:gFEdXLA+VFvSoxV+ps80q0Ergyb9l3R/4xj6Evy9z1I= netlandish.com/x/gobwebs v0.0.0-20240308002929-df98b40506b0/go.mod h1:77W9AvqBop739PH+KmyU7DpNpbM9f4iE8qyXj7GcNyE= +netlandish.com/x/gobwebs v0.0.0-20240309201308-582da32e3e94 h1:AaAvUOHYDgkLKwnX+Owtw4sXmYduL6/1jm5Vz20CWFM= +netlandish.com/x/gobwebs v0.0.0-20240309201308-582da32e3e94/go.mod h1:77W9AvqBop739PH+KmyU7DpNpbM9f4iE8qyXj7GcNyE= netlandish.com/x/gobwebs-formguard v0.0.0-20231224192353-29706d23f156 h1:kbYL/3PDS6Pt5uE5QJWkVIgd+kzUgUUb3IKhAth35Bc= netlandish.com/x/gobwebs-formguard v0.0.0-20231224192353-29706d23f156/go.mod h1:+73MG8iQ7+cs1rbcbgBEJd5so1TyFNmqrwLNKtDUAvg= netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c h1:OiR7uZB8Ix33d6uZcNucqWC53XQlJLqH5MyskIaFD20= diff --git a/helpers.go b/helpers.go index fcc9f64..7e99596 100644 --- a/helpers.go +++ b/helpers.go @@ -615,8 +615,10 @@ func GetDisabledElementsByOrg(ctx context.Context, org *models.Organization) (*C } func ArchiveURLSnapshot(ctx context.Context, orgLink *models.OrgLink) error { + // Give 5 minute timeout because it archives it during the request window + // it seems. httpClient := &http.Client{ - Timeout: time.Duration(30) * time.Second, + Timeout: time.Duration(300) * time.Second, } req, err := http.NewRequest( "GET", diff --git a/short/routes.go b/short/routes.go index a8368ef..f35c8e1 100644 --- a/short/routes.go +++ b/short/routes.go @@ -890,7 +890,11 @@ func (r *RedirectService) LinkShort(c echo.Context) error { org := orgs[0] if links.BillingEnabled(gctx.Server.Config) && org.IsRestricted( []int{models.BillingStatusFree, models.BillingStatusOpenSource}) { + lt := localizer.GetSessionLocalizer(c) + pd := localizer.NewPageData(lt.Translate("URL Shortening powered by Link Taco!")) + pd.Data["redirected"] = lt.Translate("You will be redirected in 10 seconds.") gmap := gobwebs.Map{ + "pd": pd, "url": recURL, "hideNav": true, } -- 2.43.0