Fix uneeded assume + assume after invite accept
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -198,17 +198,17 @@ func (s *AccountService) AcceptInvitation(
|
||||
ctx context.Context,
|
||||
identityID gid.GID,
|
||||
invitationID gid.GID,
|
||||
) (*coredata.Membership, error) {
|
||||
) (*coredata.Invitation, *coredata.Membership, error) {
|
||||
var (
|
||||
now = time.Now()
|
||||
membership = &coredata.Membership{}
|
||||
invitation = &coredata.Invitation{}
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(tx pg.Conn) error {
|
||||
identity := coredata.Identity{}
|
||||
invitation := coredata.Invitation{}
|
||||
|
||||
err := identity.LoadByID(ctx, tx, identityID)
|
||||
if err != nil {
|
||||
@@ -306,10 +306,10 @@ func (s *AccountService) AcceptInvitation(
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return membership, nil
|
||||
return invitation, membership, nil
|
||||
}
|
||||
|
||||
func (s *AccountService) ListPendingInvitations(
|
||||
|
||||
@@ -829,6 +829,7 @@ type RemoveMemberPayload {
|
||||
|
||||
type AcceptInvitationPayload {
|
||||
membershipEdge: MembershipEdge!
|
||||
invitation: Invitation!
|
||||
}
|
||||
|
||||
type DeleteInvitationPayload {
|
||||
|
||||
@@ -72,6 +72,7 @@ type DirectiveRoot struct {
|
||||
|
||||
type ComplexityRoot struct {
|
||||
AcceptInvitationPayload struct {
|
||||
Invitation func(childComplexity int) int
|
||||
MembershipEdge func(childComplexity int) int
|
||||
}
|
||||
|
||||
@@ -587,6 +588,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
_ = ec
|
||||
switch typeName + "." + field {
|
||||
|
||||
case "AcceptInvitationPayload.invitation":
|
||||
if e.complexity.AcceptInvitationPayload.Invitation == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.AcceptInvitationPayload.Invitation(childComplexity), true
|
||||
case "AcceptInvitationPayload.membershipEdge":
|
||||
if e.complexity.AcceptInvitationPayload.MembershipEdge == nil {
|
||||
break
|
||||
@@ -3096,6 +3103,7 @@ type RemoveMemberPayload {
|
||||
|
||||
type AcceptInvitationPayload {
|
||||
membershipEdge: MembershipEdge!
|
||||
invitation: Invitation!
|
||||
}
|
||||
|
||||
type DeleteInvitationPayload {
|
||||
@@ -3930,6 +3938,57 @@ func (ec *executionContext) fieldContext_AcceptInvitationPayload_membershipEdge(
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _AcceptInvitationPayload_invitation(ctx context.Context, field graphql.CollectedField, obj *types.AcceptInvitationPayload) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
ec.OperationContext,
|
||||
field,
|
||||
ec.fieldContext_AcceptInvitationPayload_invitation,
|
||||
func(ctx context.Context) (any, error) {
|
||||
return obj.Invitation, nil
|
||||
},
|
||||
nil,
|
||||
ec.marshalNInvitation2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐInvitation,
|
||||
true,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_AcceptInvitationPayload_invitation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "AcceptInvitationPayload",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_Invitation_id(ctx, field)
|
||||
case "email":
|
||||
return ec.fieldContext_Invitation_email(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_Invitation_fullName(ctx, field)
|
||||
case "role":
|
||||
return ec.fieldContext_Invitation_role(ctx, field)
|
||||
case "expiresAt":
|
||||
return ec.fieldContext_Invitation_expiresAt(ctx, field)
|
||||
case "acceptedAt":
|
||||
return ec.fieldContext_Invitation_acceptedAt(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Invitation_createdAt(ctx, field)
|
||||
case "status":
|
||||
return ec.fieldContext_Invitation_status(ctx, field)
|
||||
case "organization":
|
||||
return ec.fieldContext_Invitation_organization(ctx, field)
|
||||
case "permission":
|
||||
return ec.fieldContext_Invitation_permission(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type Invitation", field.Name)
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _AssumeOrganizationSessionPayload_result(ctx context.Context, field graphql.CollectedField, obj *types.AssumeOrganizationSessionPayload) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
@@ -7658,6 +7717,8 @@ func (ec *executionContext) fieldContext_Mutation_acceptInvitation(ctx context.C
|
||||
switch field.Name {
|
||||
case "membershipEdge":
|
||||
return ec.fieldContext_AcceptInvitationPayload_membershipEdge(ctx, field)
|
||||
case "invitation":
|
||||
return ec.fieldContext_AcceptInvitationPayload_invitation(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type AcceptInvitationPayload", field.Name)
|
||||
},
|
||||
@@ -15154,6 +15215,11 @@ func (ec *executionContext) _AcceptInvitationPayload(ctx context.Context, sel as
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
}
|
||||
case "invitation":
|
||||
out.Values[i] = ec._AcceptInvitationPayload_invitation(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
}
|
||||
default:
|
||||
panic("unknown field " + strconv.Quote(field.Name))
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ type AcceptInvitationInput struct {
|
||||
|
||||
type AcceptInvitationPayload struct {
|
||||
MembershipEdge *MembershipEdge `json:"membershipEdge"`
|
||||
Invitation *Invitation `json:"invitation"`
|
||||
}
|
||||
|
||||
type AssumeOrganizationSessionInput struct {
|
||||
|
||||
@@ -1006,7 +1006,7 @@ func (r *mutationResolver) AcceptInvitation(ctx context.Context, input types.Acc
|
||||
|
||||
identity := IdentityFromContext(ctx)
|
||||
|
||||
membership, err := r.iam.AccountService.AcceptInvitation(ctx, identity.ID, input.InvitationID)
|
||||
invitation, membership, err := r.iam.AccountService.AcceptInvitation(ctx, identity.ID, input.InvitationID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot accept invitation", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -1014,6 +1014,7 @@ func (r *mutationResolver) AcceptInvitation(ctx context.Context, input types.Acc
|
||||
|
||||
return &types.AcceptInvitationPayload{
|
||||
MembershipEdge: types.NewMembershipEdge(membership, coredata.MembershipOrderFieldCreatedAt),
|
||||
Invitation: types.NewInvitation(invitation),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user