Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: system-wide GitHub apps (#5114)

🏔️ Peake73c9b5f98ad
diff --git a/app/Models/GithubApp.php b/app/Models/GithubApp.php
index 0b0e93b128..5550df81f2 100644
--- a/app/Models/GithubApp.php
+++ b/app/Models/GithubApp.php
@@ -33,17 +33,30 @@ class GithubApp extends BaseModel
public static function ownedByCurrentTeam()
{
- return GithubApp::whereTeamId(currentTeam()->id);
+ return GithubApp::where(function ($query) {
+ $query->where('team_id', currentTeam()->id)
+ ->orWhere('is_system_wide', true);
+ });
}
public static function public()
{
- return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get();
+ return GithubApp::where(function ($query) {
+ $query->where(function ($q) {
+ $q->where('team_id', currentTeam()->id)
+ ->orWhere('is_system_wide', true);
+ })->where('is_public', true);
+ })->whereNotNull('app_id')->get();
}
public static function private()
{
- return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(false)->whereNotNull('app_id')->get();
+ return GithubApp::where(function ($query) {
+ $query->where(function ($q) {
+ $q->where('team_id', currentTeam()->id)
+ ->orWhere('is_system_wide', true);
+ })->where('is_public', false);
+ })->whereNotNull('app_id')->get();
}
public function team()
diff --git a/app/Models/Team.php b/app/Models/Team.php
index 07959dd169..467cf45bc4 100644
--- a/app/Models/Team.php
+++ b/app/Models/Team.php
@@ -248,15 +248,17 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
{
$sources = collect([]);
$github_apps = GithubApp::where(function ($query) {
- $query->where('team_id', $this->id)
- ->Where('is_public', false)
- ->orWhere('is_system_wide', true);
+ $query->where(function ($q) {
+ $q->where('team_id', $this->id)
+ ->orWhere('is_system_wide', true);
+ })->where('is_public', false);
})->get();
$gitlab_apps = GitlabApp::where(function ($query) {
- $query->where('team_id', $this->id)
- ->Where('is_public', false)
- ->orWhere('is_system_wide', true);
+ $query->where(function ($q) {
+ $q->where('team_id', $this->id)
+ ->orWhere('is_system_wide', true);
+ })->where('is_public', false);
})->get();
return $sources->merge($github_apps)->merge($gitlab_apps);