From db5786efc9aeedf082a2804f6c1f00da6e7869b0 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:14:36 +0100 Subject: [PATCH] fix: instance wide GitHub apps are not available on other teams then the source team --- app/Models/Team.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Models/Team.php b/app/Models/Team.php index 8651df3c8..07959dd16 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -247,8 +247,17 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen public function sources() { $sources = collect([]); - $github_apps = $this->hasMany(GithubApp::class)->whereisPublic(false)->get(); - $gitlab_apps = $this->hasMany(GitlabApp::class)->whereisPublic(false)->get(); + $github_apps = GithubApp::where(function ($query) { + $query->where('team_id', $this->id) + ->Where('is_public', false) + ->orWhere('is_system_wide', true); + })->get(); + + $gitlab_apps = GitlabApp::where(function ($query) { + $query->where('team_id', $this->id) + ->Where('is_public', false) + ->orWhere('is_system_wide', true); + })->get(); return $sources->merge($github_apps)->merge($gitlab_apps); }