fix(user-deletion): handle GitHub app sources across team cleanup

Limit team cleanup to apps owned by the deleted team and nullify cross-team application source references before deleting team-owned sources. Adds feature tests covering user deletion with GitHub app-backed applications, preserving system-wide apps, and nullifying external source links.
This commit is contained in:
Andras Bacsai committed 2026-04-05 18:08:06 +02:00
1 parent 968508583d
commit 3f564f9b2e
3 files changed
+187 -2

No files matched your search

+4 -2
View File
@@ -76,8 +76,10 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
foreach ($keys as $key) {
$key->delete();
}
$sources = $team->sources();
foreach ($sources as $source) {
// Only delete sources owned by this team, not system-wide ones from other teams
$teamSources = GithubApp::where('team_id', $team->id)->get()
->merge(GitlabApp::where('team_id', $team->id)->get());
foreach ($teamSources as $source) {
$source->delete();
}
$tags = Tag::whereTeamId($team->id)->get();