Require a verified viewer email before creating a rights request and validate the free-text fields with the same SafeText bounds the console uses, so this public portal mutation stays safe and bounded. Move myRightsRequests onto the base Query, drop the now-dead count loaders, and order the RECTIFICATION enum value before PORTABILITY so the Postgres sort order matches RightsRequestTypes(). Harden the v2 kit primitives: SegmentedControl keeps equal-width cards (auto-fill), preserves its selection when the active card is toggled, and forwards an accessible name; Field associates its label and error by id/aria instead of wrapping the control in a label. Give the type group an accessible name, require the name field for non-complaint types, use a timezone-stable reference year, drop the underreporting header count, and neutralize the response-deadline copy. Signed-off-by: Émile Ré <emile@probo.com>
55 lines
1.9 KiB
Go
55 lines
1.9 KiB
Go
package trust_v1
|
|
|
|
// This file will be automatically regenerated based on the schema, any resolver
|
|
// implementations
|
|
// will be copied through when generating and any unknown code will be moved to the end.
|
|
// Code generated by github.com/99designs/gqlgen version v0.17.93
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.gearno.de/kit/log"
|
|
"go.probo.inc/probo/pkg/coredata"
|
|
"go.probo.inc/probo/pkg/server/api/authn"
|
|
"go.probo.inc/probo/pkg/server/api/compliancepage"
|
|
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
|
|
"go.probo.inc/probo/pkg/server/gqlutils"
|
|
"go.probo.inc/probo/pkg/trust"
|
|
)
|
|
|
|
// CreateRightsRequest is the resolver for the createRightsRequest field.
|
|
func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types.CreateRightsRequestInput) (*types.CreateRightsRequestPayload, error) {
|
|
identity := authn.IdentityFromContext(ctx)
|
|
if identity == nil || !identity.EmailAddressVerified {
|
|
// The request is attributed to the viewer's email, so the email must be
|
|
// verified — an authenticated-but-unverified identity is not enough.
|
|
return nil, gqlutils.Unauthenticatedf(ctx, "a verified email is required to submit a request")
|
|
}
|
|
|
|
compliancePage := compliancepage.CompliancePageFromContext(ctx)
|
|
scope := coredata.NewScopeFromObjectID(compliancePage.OrganizationID)
|
|
|
|
rightsRequest, err := r.trust.RightsRequests.Create(
|
|
ctx,
|
|
scope,
|
|
&trust.CreateRightsRequest{
|
|
OrganizationID: compliancePage.OrganizationID,
|
|
RequestType: input.RequestType,
|
|
DataSubject: input.DataSubject,
|
|
Contact: identity.EmailAddress.String(),
|
|
Details: input.Details,
|
|
},
|
|
)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot create rights request", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateRightsRequestPayload{
|
|
RightsRequestEdge: types.NewRightsRequestEdge(
|
|
rightsRequest,
|
|
coredata.RightsRequestOrderFieldCreatedAt,
|
|
),
|
|
}, nil
|
|
}
|