fix: remove private key in case you removed a github app

This commit is contained in:
Andras Bacsai 2023-09-29 11:01:40 +02:00
parent f4819a849b
commit ac133875fa

View File

@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
class GithubApp extends BaseModel
{
protected $guarded = [];
protected $appends = ['type'];
protected $casts = [
@ -17,6 +18,7 @@ class GithubApp extends BaseModel
'webhook_secret',
];
static public function public()
{
return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get();
@ -34,6 +36,7 @@ class GithubApp extends BaseModel
if ($applications_count > 0) {
throw new \Exception('You cannot delete this GitHub App because it is in use by ' . $applications_count . ' application(s). Delete them first.');
}
$github_app->privateKey()->delete();
});
}