Skip to content

Commit 4f0e17c

Browse files
committed
[server] When a user attributes all their usage to a team, but then leaves that team, reset their selected 'usageAttributionId'
1 parent 83dc8b5 commit 4f0e17c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

components/server/ee/src/workspace/gitpod-server-impl.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,18 +1438,12 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
14381438

14391439
protected async onTeamMemberRemoved(userId: string, teamId: string, teamMembershipId: string): Promise<void> {
14401440
const now = new Date();
1441-
const teamSubscription = await this.teamSubscription2DB.findForTeam(teamId, now.toISOString());
1442-
if (!teamSubscription) {
1443-
// No team subscription, nothing to do 🌴
1444-
return;
1441+
const ts2 = await this.teamSubscription2DB.findForTeam(teamId, now.toISOString());
1442+
if (ts2) {
1443+
await this.updateTeamSubscriptionQuantity(ts2);
1444+
await this.teamSubscription2Service.cancelTeamMemberSubscription(ts2, userId, teamMembershipId, now);
14451445
}
1446-
await this.updateTeamSubscriptionQuantity(teamSubscription);
1447-
await this.teamSubscription2Service.cancelTeamMemberSubscription(
1448-
teamSubscription,
1449-
userId,
1450-
teamMembershipId,
1451-
now,
1452-
);
1446+
// TODO(janx): If Stripe subscription && user.attributionTeamId === teamId --> unset user.attributionTeamId
14531447
}
14541448

14551449
protected async onTeamDeleted(teamId: string): Promise<void> {

0 commit comments

Comments
 (0)