package complianceportal_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.94 import ( "context" "go.gearno.de/kit/log" "go.probo.inc/probo/pkg/complianceportal/visitor" "go.probo.inc/probo/pkg/coredata" "go.probo.inc/probo/pkg/server/api/authn" "go.probo.inc/probo/pkg/server/api/complianceportal" "go.probo.inc/probo/pkg/server/api/complianceportal/v1/types" "go.probo.inc/probo/pkg/server/gqlutils" ) // 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 := complianceportal.CompliancePortalFromContext(ctx) scope := coredata.NewScopeFromObjectID(compliancePage.OrganizationID) rightsRequest, err := r.visitor.CreateRightsRequest( ctx, scope, &visitor.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 }