Skip to content

Commit 8642d70

Browse files
committed
[server] When a user with no explicit 'usageAttributionId' joins a team with usage-based billing enabled, automatically re-attribute usage to that team
1 parent 490419b commit 8642d70

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,13 +1428,12 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
14281428

14291429
protected async onTeamMemberAdded(userId: string, teamId: string): Promise<void> {
14301430
const now = new Date();
1431-
const teamSubscription = await this.teamSubscription2DB.findForTeam(teamId, now.toISOString());
1432-
if (!teamSubscription) {
1433-
// No team subscription, nothing to do 🌴
1434-
return;
1431+
const ts2 = await this.teamSubscription2DB.findForTeam(teamId, now.toISOString());
1432+
if (ts2) {
1433+
await this.updateTeamSubscriptionQuantity(ts2);
1434+
await this.teamSubscription2Service.addTeamMemberSubscription(ts2, userId);
14351435
}
1436-
await this.updateTeamSubscriptionQuantity(teamSubscription);
1437-
await this.teamSubscription2Service.addTeamMemberSubscription(teamSubscription, userId);
1436+
// TODO(janx): If Stripe subscription && !user.attributionTeamId --> set user.attributionTeamId to teamId
14381437
}
14391438

14401439
protected async onTeamMemberRemoved(userId: string, teamId: string, teamMembershipId: string): Promise<void> {

0 commit comments

Comments
 (0)