fix: instance wide GitHub apps are not available on other teams then the source team

This commit is contained in:
peaklabs-dev
2025-01-13 12:14:36 +01:00
parent 706602b3a8
commit db5786efc9

View File

@@ -247,8 +247,17 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
public function sources() public function sources()
{ {
$sources = collect([]); $sources = collect([]);
$github_apps = $this->hasMany(GithubApp::class)->whereisPublic(false)->get(); $github_apps = GithubApp::where(function ($query) {
$gitlab_apps = $this->hasMany(GitlabApp::class)->whereisPublic(false)->get(); $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); return $sources->merge($github_apps)->merge($gitlab_apps);
} }