@@ -75,6 +75,12 @@ export class GithubSubscriptionMapper {
75
75
plan : Plan ,
76
76
model : SubscriptionModel ,
77
77
) {
78
+ if ( Plans . isFreePlan ( plan . chargebeeId ) ) {
79
+ // don't sync free plans, as we cover those explicitly
80
+ log . debug ( { userId : user . id } , "skip syncing purchased free plan" , { plan } ) ;
81
+ return ;
82
+ }
83
+
78
84
model . add (
79
85
Subscription . create ( {
80
86
userId : user . id ,
@@ -119,13 +125,13 @@ export class GithubSubscriptionMapper {
119
125
public mapSubscriptionChange ( user : User , context : ChangeContext , model : SubscriptionModel ) {
120
126
const { prevPlan, oldSubscription, newAmount, newStartDate, newPlan } = context ;
121
127
122
- if ( prevPlan . type == "free" ) {
128
+ if ( Plans . isFreePlan ( prevPlan . type ) ) {
123
129
// we've changed from the free plan which means we've purchased a new subscription
124
130
log . debug ( { userId : user . id } , "upgrading from free plan" ) ;
125
131
this . mapSubscriptionPurchase ( user , context . accountID , context . effectiveDate , newPlan , model ) ;
126
132
return ;
127
133
}
128
- if ( newPlan . type == "free" ) {
134
+ if ( Plans . isFreePlan ( newPlan . type ) ) {
129
135
// we've changed to the free plan which means we're canceling the current subscription
130
136
log . debug ( { userId : user . id } , "downgrading to free plan" ) ;
131
137
this . mapSubscriptionCancel ( user . id , new Date ( ) . toISOString ( ) , model ) ;
0 commit comments