Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/github/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hawk.so/github-sdk",
"version": "1.0.3",
"version": "1.0.4",
"description": "GitHub API client for Hawk (GitHub App, Issues, OAuth)",
"author": "CodeX <team@codex.so>",
"license": "AGPL-3.0-only",
Expand Down
6 changes: 6 additions & 0 deletions packages/github/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ export class GitHubService {
installation_id: parseInt(installationId, 10),
});

let accountId = 0;
let accountLogin = '';
let accountType = '';

if (data.account) {
if ('id' in data.account) {
accountId = data.account.id;
}

if ('login' in data.account) {
accountLogin = data.account.login;
accountType = 'login' in data.account && 'type' in data.account ? data.account.type : 'User';
Expand All @@ -152,6 +157,7 @@ export class GitHubService {
return {
id: data.id,
account: {
id: accountId,
login: accountLogin,
type: accountType,
},
Expand Down
2 changes: 2 additions & 0 deletions packages/github/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export type Installation = {
id: number;
/** Account where the app is installed. */
account: {
/** GitHub account ID. */
id: number;
/** GitHub username or org login. */
login: string;
/** Account type (e.g. "User", "Organization"). */
Expand Down
2 changes: 2 additions & 0 deletions packages/github/tests/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ describe('GitHubService', () => {
expect(result).toEqual({
id: 12345,
account: {
id: 1,
login: 'octocat',
type: 'User',
},
Expand Down Expand Up @@ -203,6 +204,7 @@ describe('GitHubService', () => {
expect(result).toEqual({
id: 12345,
account: {
id: 1,
login: 'my-org',
type: 'Organization',
},
Expand Down