From 2b83d63e071115e4ccf6bb662c18ad6f2790f6fd Mon Sep 17 00:00:00 2001 From: Adela Homolova Date: Mon, 9 Dec 2019 15:05:23 +0100 Subject: [PATCH] fix: get the ownerId via repo info with one request --- src/services/bitbucket/BitbucketService.ts | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/services/bitbucket/BitbucketService.ts b/src/services/bitbucket/BitbucketService.ts index 03781f57e..07dfbd348 100644 --- a/src/services/bitbucket/BitbucketService.ts +++ b/src/services/bitbucket/BitbucketService.ts @@ -96,15 +96,7 @@ export class BitbucketService implements IVCSService { const ownerUrl = `www.bitbucket.org/${owner}`; - //Bitbucket uses two types of accounts - user and team. The request for users' uuid fails if it is a team account. - let ownerId: string; - try { - ownerId = `${(await this.client.users.get({ username: owner })).data.uuid}`; - } catch (error) { - if (error.message.includes('is a team account')) { - ownerId = `${(await this.client.teams.get({ username: owner })).data.uuid}`; - } - } + const ownerId = (await this.client.repositories.get({ repo_slug: repo, username: owner })).data.owner?.uuid; const response: DeepRequired> = await axios.get(apiUrl); @@ -154,15 +146,8 @@ export class BitbucketService implements IVCSService { }; const ownerUrl = `www.bitbucket.org/${owner}`; - //Bitbucket use two types of accounts - user and team. The request for users uuid fails if it is a team account. - let ownerId = ''; - try { - ownerId = `${(await this.client.users.get({ username: owner })).data.uuid}`; - } catch (error) { - if (error.message.includes('is a team account')) { - ownerId = `${(await this.client.teams.get({ username: owner })).data.uuid}`; - } - } + const ownerId = (await this.client.repositories.get({ repo_slug: repo, username: owner })).data.owner?.uuid; + const response = >>await this.client.pullrequests.get(params); response.data;