Skip to content

Commit c5054d0

Browse files
committed
Also delete any LinkedIn profile when deleting a user account
1 parent da6b19e commit c5054d0

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

components/gitpod-db/src/linked-in-profile-db.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ import { LinkedInProfile } from "@gitpod/gitpod-protocol";
99
export const LinkedInProfileDB = Symbol("LinkedInProfileDB");
1010
export interface LinkedInProfileDB {
1111
storeProfile(userId: string, profile: LinkedInProfile): Promise<void>;
12+
deleteProfile(userId: string): Promise<void>;
1213
}

components/gitpod-db/src/typeorm/linked-in-profile-db-impl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ export class LinkedInProfileDBImpl implements LinkedInProfileDB {
4141
creationTime: existingProfile?.creationTime || new Date().toISOString(),
4242
});
4343
}
44+
45+
public async deleteProfile(userId: string): Promise<void> {
46+
const repo = await this.getRepo();
47+
await repo.delete({ userId });
48+
}
4449
}

components/server/src/linkedin-service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export class LinkedInService {
2626
return profile;
2727
}
2828

29+
async deleteLinkedInProfile(userId: string): Promise<void> {
30+
await this.linkedInProfileDB.deleteProfile(userId);
31+
}
32+
2933
private async getAccessToken(code: string) {
3034
const { clientId, clientSecret } = this.config.linkedInSecrets || {};
3135
if (!clientId || !clientSecret) {

components/server/src/user/user-deletion-service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { IAnalyticsWriter } from "@gitpod/gitpod-protocol/lib/analytics";
1717
import { Config } from "../config";
1818
import { StripeService } from "../../ee/src/user/stripe-service";
1919
import { BillingModes } from "../../ee/src/billing/billing-mode";
20+
import { LinkedInService } from "../linkedin-service";
2021

2122
@injectable()
2223
export class UserDeletionService {
@@ -34,6 +35,7 @@ export class UserDeletionService {
3435
@inject(IAnalyticsWriter) protected readonly analytics: IAnalyticsWriter;
3536
@inject(StripeService) protected readonly stripeService: StripeService;
3637
@inject(BillingModes) protected readonly billingMode: BillingModes;
38+
@inject(LinkedInService) protected readonly linkedInService: LinkedInService;
3739

3840
/**
3941
* This method deletes a User logically. The contract here is that after running this method without receiving an
@@ -93,6 +95,8 @@ export class UserDeletionService {
9395
this.deleteTeamMemberships(id),
9496
// User projects
9597
this.deleteUserProjects(id),
98+
// LinkedIn profile
99+
this.deleteLinkedInProfile(id),
96100
]);
97101

98102
// Track the deletion Event for Analytics Purposes
@@ -220,6 +224,14 @@ export class UserDeletionService {
220224
await Promise.all(userProjects.map((project) => this.projectDb.markDeleted(project.id)));
221225
}
222226

227+
protected async deleteLinkedInProfile(userId: string) {
228+
try {
229+
await this.linkedInService.deleteLinkedInProfile(userId);
230+
} catch (error) {
231+
log.error({ userId: userId }, "Failed to delete user's LinkedIn profile.", error);
232+
}
233+
}
234+
223235
anonymizeWorkspace(ws: Workspace) {
224236
ws.context.title = "deleted-title";
225237
ws.context.normalizedContextURL = "deleted-normalizedContextURL";

0 commit comments

Comments
 (0)