Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
prevent archived subscription from being updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Aug 9, 2024
1 parent 40d9193 commit 06eecf1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/enterprise-portal/internal/subscriptionsservice/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,14 @@ func (s *handlerV1) UpdateEnterpriseSubscription(ctx context.Context, req *conne
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("subscription.id is required"))
}

if _, err := s.store.GetEnterpriseSubscription(ctx, subscriptionID); err != nil {
if existing, err := s.store.GetEnterpriseSubscription(ctx, subscriptionID); err != nil {
if errors.Is(err, subscriptions.ErrSubscriptionNotFound) {
return nil, connect.NewError(connect.CodeNotFound, err)
}
return nil, connectutil.InternalError(ctx, logger, err, "failed to find subscription")
} else if existing.ArchivedAt != nil {
return nil, connect.NewError(connect.CodeInvalidArgument,
errors.New("archived subscriptions cannot be updated"))
}

var opts subscriptions.UpsertSubscriptionOptions
Expand Down

0 comments on commit 06eecf1

Please sign in to comment.