Skip to content

Commit

Permalink
fix: Limit the collaborator fields stored in Elasticsearch
Browse files Browse the repository at this point in the history
Avoids issues with invalid users not matching the detected schema
  • Loading branch information
baumandm committed Feb 28, 2023
1 parent 676a594 commit 49b5ce1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/backend/src/lib/backends/github.sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,17 @@ async function getInsightContributors(insight: IndexedInsight, yaml: InsightYaml
async function getInsightCollaborators(insight: IndexedInsight): Promise<IndexedInsightCollaborator[]> {
const insightService = Container.get(InsightService);

return await insightService.getCollaborators(insight as Insight);
const collaborators = await insightService.getCollaborators(insight as Insight);

// Return only the fields we need
return collaborators.map(({ permission, user }) => ({
permission,
user: {
userName: user.userName,
displayName: user.displayName,
email: user.email
}
}));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ import type { RepositoryPermission } from '../repository-permission';
import type { IndexedInsightUser } from './indexed-insight-user';

export interface IndexedInsightCollaborator {
user: IndexedInsightUser;
user: Pick<IndexedInsightUser, 'userName' | 'displayName' | 'email'>;
permission: RepositoryPermission;
}

0 comments on commit 49b5ce1

Please sign in to comment.