~netlandish/links

a746c61886c37585bad463c2bdf4ec22900df7a3 — Peter Sanchez a month ago 1b983bf
Adding 5 minute timeout for Web Archive request
M api/graph/generated.go => api/graph/generated.go +2 -22
@@ 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)

M api/graph/schema.graphqls => api/graph/schema.graphqls +1 -1
@@ 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

M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +1 -1
@@ 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"

M core/routes.go => core/routes.go +1 -1
@@ 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,

M go.mod => go.mod +1 -1
@@ 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

M go.sum => go.sum +2 -0
@@ 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=

M helpers.go => helpers.go +3 -1
@@ 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",

M short/routes.go => short/routes.go +4 -0
@@ 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,
		}