Skip to content

Also delete any LinkedIn profile when deleting a user account #17388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/gitpod-db/src/linked-in-profile-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import { LinkedInProfile } from "@gitpod/gitpod-protocol";
export const LinkedInProfileDB = Symbol("LinkedInProfileDB");
export interface LinkedInProfileDB {
storeProfile(userId: string, profile: LinkedInProfile): Promise<void>;
deleteProfile(userId: string): Promise<void>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ export class LinkedInProfileDBImpl implements LinkedInProfileDB {
creationTime: existingProfile?.creationTime || new Date().toISOString(),
});
}

public async deleteProfile(userId: string): Promise<void> {
const repo = await this.getRepo();
await repo.delete({ userId });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this throw if the userId does not exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation says:

Deletes entities by a given criteria. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient DELETE query. Does not check if entity exist in the database.

}
}
4 changes: 4 additions & 0 deletions components/server/src/linkedin-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class LinkedInService {
return profile;
}

async deleteLinkedInProfile(userId: string): Promise<void> {
await this.linkedInProfileDB.deleteProfile(userId);
}

private async getAccessToken(code: string) {
const { clientId, clientSecret } = this.config.linkedInSecrets || {};
if (!clientId || !clientSecret) {
Expand Down
8 changes: 8 additions & 0 deletions components/server/src/user/user-deletion-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Config } from "../config";
import { StripeService } from "../../ee/src/user/stripe-service";
import { BillingModes } from "../../ee/src/billing/billing-mode";
import { WorkspaceStarter } from "../workspace/workspace-starter";
import { LinkedInService } from "../linkedin-service";

@injectable()
export class UserDeletionService {
Expand All @@ -33,6 +34,7 @@ export class UserDeletionService {
@inject(IAnalyticsWriter) protected readonly analytics: IAnalyticsWriter;
@inject(StripeService) protected readonly stripeService: StripeService;
@inject(BillingModes) protected readonly billingMode: BillingModes;
@inject(LinkedInService) protected readonly linkedInService: LinkedInService;

/**
* This method deletes a User logically. The contract here is that after running this method without receiving an
Expand Down Expand Up @@ -97,6 +99,8 @@ export class UserDeletionService {
this.deleteTeamMemberships(id),
// User projects
this.deleteUserProjects(id),
// LinkedIn profile
this.deleteLinkedInProfile(id),
]);

// Track the deletion Event for Analytics Purposes
Expand Down Expand Up @@ -181,6 +185,10 @@ export class UserDeletionService {
await Promise.all(userProjects.map((project) => this.projectDb.markDeleted(project.id)));
}

protected async deleteLinkedInProfile(userId: string) {
await this.linkedInService.deleteLinkedInProfile(userId);
}

anonymizeWorkspace(ws: Workspace) {
ws.context.title = "deleted-title";
ws.context.normalizedContextURL = "deleted-normalizedContextURL";
Expand Down