diff --git a/api/backends/entities.py b/api/backends/entities.py index 1cb022f6..c6214ac5 100644 --- a/api/backends/entities.py +++ b/api/backends/entities.py @@ -103,6 +103,7 @@ def __init__( contributions: Optional[int] = None, bio: Optional[str] = None, keys: Optional[str] = None, + key_id: Optional[str] = None, ): match contributions, bio, keys: case None, None, None: @@ -129,6 +130,7 @@ def __init__( avatar_url=avatar_url, html_url=html_url, bio=bio, + key_id=key_id, ) case int(_), str(_), str(_): dict.__init__( diff --git a/api/backends/github.py b/api/backends/github.py index 82a5c452..257e7309 100644 --- a/api/backends/github.py +++ b/api/backends/github.py @@ -98,7 +98,7 @@ async def __assemble_contributor( ) -> Contributor: match team_view: case True: - keys = {"login", "avatar_url", "html_url", "bio"} + keys = {"login", "avatar_url", "html_url", "bio", "key_id"} case _: keys = {"login", "avatar_url", "html_url", "contributions"} @@ -107,11 +107,6 @@ async def __assemble_contributor( contributor, ) - if team_view: - filter_contributor["keys"] = ( - f"{base_url.replace('api.', '')}/{filter_contributor['login']}.gpg" - ) - return Contributor(**filter_contributor) @staticmethod @@ -313,6 +308,18 @@ async def get_team_members(self, repository: GithubRepository) -> list[Contribut user_data_response, ) ) + + for index, user in enumerate(user_data): + response: ClientResponse = await http_get( + headers=self.headers, url=f"{base_url}/users/{user['login']}/gpg_keys" + ) + output = await response.json() + + if len(output) is not 0: + user_data[index]["key_id"] = output[0]["key_id"] + else: + user_data[index]["key_id"] = "" + team_members: list[Contributor] = await asyncio.gather( *map( lambda member: self.__assemble_contributor(member, team_view=True),