From 0dcc361a181e06f3ae12a003948ddd59c3e31f7e Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Sat, 24 Aug 2024 10:43:27 +0100 Subject: [PATCH] chore: if and throw for null types --- src/handlers/watch-user-activity.ts | 6 +++++- src/helpers/get-watched-repos.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/handlers/watch-user-activity.ts b/src/handlers/watch-user-activity.ts index 1c781e1..1caae0c 100644 --- a/src/handlers/watch-user-activity.ts +++ b/src/handlers/watch-user-activity.ts @@ -22,8 +22,12 @@ export async function watchUserActivity(context: Context) { async function updateReminders(context: Context, repo: ListForOrg["data"][0]) { const { logger, octokit, payload } = context; + const owner = payload.repository.owner?.login; + if (!owner) { + throw new Error("No owner found in the payload"); + } const issues = (await octokit.paginate(octokit.rest.issues.listForRepo, { - owner: payload.repository.owner.login, + owner, repo: repo.name, per_page: 100, state: "open", diff --git a/src/helpers/get-watched-repos.ts b/src/helpers/get-watched-repos.ts index f0ade6d..a261367 100644 --- a/src/helpers/get-watched-repos.ts +++ b/src/helpers/get-watched-repos.ts @@ -8,7 +8,11 @@ export async function getWatchedRepos(context: Context) { }, } = context; const repoNames = new Set(); - const orgRepos = await getReposForOrg(context, context.payload.repository.owner.login); + const owner = context.payload.repository.owner?.login; + if (!owner) { + throw new Error("No owner found in the payload"); + } + const orgRepos = await getReposForOrg(context, owner); orgRepos.forEach((repo) => repoNames.add(repo.name.toLowerCase())); for (const repo of optOut) {