~netlandish/links-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH links] api: getDomains return system domains if no org slug is specifically specified.

Details
Message ID
<20260301172947.29644-1-peter@netlandish.com>
Sender timestamp
1772364584
DKIM signature
missing
Download raw message
Patch: +25 -10
Also fix issue when referencing a short link short code before
verification that it was sent to the backend.

Changelog-updated: getDomains to return system domains when no
 organization slug is passed.
Changelog-updated: API version bumped to 0.10.3
Changelog-fixed: bug when shortCode is referenced before verification
 that it was passed
---
 api/graph/schema.resolvers.go | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go
index 120051b..aab1ba5 100644
--- a/api/graph/schema.resolvers.go
+++ b/api/graph/schema.resolvers.go
@@ -33,6 +33,7 @@ import (
	"time"

	sq "github.com/Masterminds/squirrel"
	"github.com/microcosm-cc/bluemonday"
	"github.com/segmentio/ksuid"
	qrcode "github.com/yeqown/go-qrcode/v2"
	"github.com/yeqown/go-qrcode/writer/standard"
@@ -42,7 +43,6 @@ import (
	auditlog "netlandish.com/x/gobwebs-auditlog"
	oauth2 "netlandish.com/x/gobwebs-oauth2"
	gaccounts "netlandish.com/x/gobwebs/accounts"
	"github.com/microcosm-cc/bluemonday"
	"netlandish.com/x/gobwebs/crypto"
	"netlandish.com/x/gobwebs/database"
	"netlandish.com/x/gobwebs/email"
@@ -2299,13 +2299,14 @@ func (r *mutationResolver) AddLinkShort(ctx context.Context, input *model.LinkSh
			"%s", lt.Translate("Short Code may not exceed 20 characters")).
			WithField("shortCode").
			WithCode(valid.ErrValidationCode)
	}
	b := &gaccounts.BlacklistValidator{}
	if !b.UsernameSafePlus(links.InvalidSlugs, *input.ShortCode) {
		validator.Error("%s", lt.Translate("This shortCode can not be used. Please chose another one")).
			WithField("shortCode").
			WithCode(valid.ErrValidationCode)
		return nil, nil

		b := &gaccounts.BlacklistValidator{}
		if !b.UsernameSafePlus(links.InvalidSlugs, *input.ShortCode) {
			validator.Error("%s", lt.Translate("This shortCode can not be used. Please chose another one")).
				WithField("shortCode").
				WithCode(valid.ErrValidationCode)
			return nil, nil
		}
	}

	tags := make([]string, 0)
@@ -5126,7 +5127,7 @@ func (r *queryResolver) Version(ctx context.Context) (*model.Version, error) {
	return &model.Version{
		Major:           0,
		Minor:           10,
		Patch:           2,
		Patch:           3,
		DeprecationDate: nil,
	}, nil
}
@@ -5906,7 +5907,10 @@ func (r *queryResolver) GetDomains(ctx context.Context, orgSlug *string, service

	ctx = timezone.Context(ctx, links.GetUserTZ(user))

	var org *models.Organization
	var (
		org     *models.Organization
		orgSent bool
	)
	orgs, err := user.GetOrgs(ctx, models.OrgUserPermissionRead)
	if err != nil {
		return nil, err
@@ -5920,6 +5924,7 @@ func (r *queryResolver) GetDomains(ctx context.Context, orgSlug *string, service
			}
		}
	} else {
		orgSent = true
		for _, o := range orgs {
			if o.Slug == *orgSlug {
				org = o
@@ -5939,6 +5944,16 @@ func (r *queryResolver) GetDomains(ctx context.Context, orgSlug *string, service
	opts := &database.FilterOptions{
		Filter: sq.Eq{"d.org_id": org.ID},
	}
	if !orgSent {
		// If no organization is specified then include system level domains as well
		opts.Filter = sq.Or{
			opts.Filter,
			sq.And{
				sq.Eq{"d.org_id": nil},
				sq.Eq{"d.level": models.DomainLevelSystem},
			},
		}
	}
	if service != nil {
		opts.Filter = sq.And{
			opts.Filter,
-- 
2.52.0
Details
Message ID
<DGSKMPKZDWUP.2CLSLE77FR14W@netlandish.com>
In-Reply-To
<20260301172947.29644-1-peter@netlandish.com> (view parent)
Sender timestamp
1772460965
DKIM signature
missing
Download raw message
Applied.

To git@git.code.netlandish.com:~netlandish/links
   a63d31d..362b220  master -> master
Reply to thread Export thread (mbox)