diff --git a/src/api/db/build.ts b/src/api/db/build.ts index e91d7c627..70914c699 100644 --- a/src/api/db/build.ts +++ b/src/api/db/build.ts @@ -33,7 +33,8 @@ export function getBuilds(limit: number, offset: number): Promise { export function getBuild(id: number): Promise { return new Promise((resolve, reject) => { - new Build({ id: id }).fetch({ withRelated: ['repository', 'jobs.runs', 'runs.job_runs'] }) + new Build({ id: id }) + .fetch({ withRelated: ['repository.access_token', 'jobs.runs', 'runs.job_runs'] }) .then(build => { if (!build) { reject(); @@ -63,6 +64,7 @@ export function getBuild(id: number): Promise { return run; }); + build.repository.access_token = build.repository.access_token.token || null; return build; }) .then(build => { diff --git a/src/api/db/repository.ts b/src/api/db/repository.ts index 778b96475..524345415 100644 --- a/src/api/db/repository.ts +++ b/src/api/db/repository.ts @@ -46,7 +46,10 @@ export function getRepositoryOnly(id: number): Promise { if (!repo) { reject(repo); } else { - resolve(repo.toJSON()); + repo = repo.toJSON(); + repo.access_token = repo.access_token.token || null; + + resolve(repo); } }).catch(err => reject(err)); });