Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 165283a

Browse files
committed
Better nil handling
1 parent 5ac0893 commit 165283a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cmd/profile-async/main.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func handleConwaySync(ctx context.Context, env *conf.Env, kc *keycloak.Keycloak[
113113
"fob_id": user.FobID,
114114
"stripe_customer_id": user.StripeCustomerID,
115115
"stripe_subscription_id": user.StripeSubscriptionID,
116-
"stripe_subscription_state": "inactive",
116+
"stripe_subscription_state": nil,
117117
"stripe_cancelation_time": nil,
118118
"paypal_subscription_id": user.PaypalMetadata.TransactionID,
119119
"paypal_price": user.PaypalMetadata.Price,
@@ -123,6 +123,18 @@ func handleConwaySync(ctx context.Context, env *conf.Env, kc *keycloak.Keycloak[
123123
if out["fob_id"] == 0 {
124124
out["fob_id"] = nil
125125
}
126+
if out["stripe_customer_id"] == "" {
127+
out["stripe_customer_id"] = nil
128+
}
129+
if out["stripe_subscription_id"] == "" {
130+
out["stripe_subscription_id"] = nil
131+
}
132+
if out["paypal_subscription_id"] == "" {
133+
out["paypal_subscription_id"] = nil
134+
}
135+
if out["paypal_price"] == float64(0) {
136+
out["paypal_price"] = nil
137+
}
126138
if user.PaypalMetadata.TimeRFC3339.After(time.Unix(0, 0)) {
127139
out["paypal_last_payment"] = user.PaypalMetadata.TimeRFC3339.Unix()
128140
}

0 commit comments

Comments
 (0)