Skip to content

Commit 3c5f0b4

Browse files
authored
Merge branch 'main' into developer-plugin-terms
2 parents 09be8cf + 864d848 commit 3c5f0b4

10 files changed

Lines changed: 80 additions & 14 deletions

File tree

app/Http/Controllers/GitHubIntegrationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function handleCallback(): RedirectResponse
5757
'trace' => $e->getTraceAsString(),
5858
]);
5959

60-
$route = Auth::check() ? 'customer.licenses' : 'customer.login';
60+
$route = Auth::check() ? 'customer.licenses.list' : 'customer.login';
6161

6262
return to_route($route)
6363
->with('error', 'GitHub authentication failed. Please try again.');

app/Livewire/LeadSubmissionForm.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Rules\Turnstile;
99
use Illuminate\Support\Facades\Notification;
1010
use Illuminate\Support\Facades\RateLimiter;
11+
use Livewire\Attributes\Locked;
1112
use Livewire\Component;
1213

1314
class LeadSubmissionForm extends Component
@@ -24,6 +25,7 @@ class LeadSubmissionForm extends Component
2425

2526
public string $turnstileToken = '';
2627

28+
#[Locked]
2729
public bool $submitted = false;
2830

2931
protected function rules(): array

app/Livewire/OrderSuccess.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ public function loadData(): void
5959
return;
6060
}
6161

62-
$this->subscription = Subscription::fromStripePriceId($subscriptionItem->stripe_price);
62+
try {
63+
$this->subscription = Subscription::fromStripePriceId($subscriptionItem->stripe_price);
64+
} catch (\RuntimeException $e) {
65+
report($e);
66+
67+
return;
68+
}
69+
6370
$this->email = $subscriptionRecord->user->email;
6471
$this->licenseKey = License::query()
6572
->whereBelongsTo($subscriptionItem)

app/Livewire/VersionSwitcher.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
namespace App\Livewire;
44

55
use Illuminate\View\ViewException;
6+
use Livewire\Attributes\Locked;
67
use Livewire\Component;
78

89
class VersionSwitcher extends Component
910
{
11+
#[Locked]
1012
public string $platform;
1113

14+
#[Locked]
1215
public array $versions;
1316

1417
public int $version;
1518

19+
#[Locked]
1620
public string $page;
1721

1822
public function mount(array $versions)

app/Models/Plugin.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ public static function findByVendorPackageOrFail(string $vendor, string $package
4747
*/
4848
public function routeParams(): array
4949
{
50-
[$vendor, $package] = explode('/', $this->name);
50+
$parts = explode('/', $this->name ?? '');
5151

52-
return ['vendor' => $vendor, 'package' => $package];
52+
return [
53+
'vendor' => $parts[0] ?? '',
54+
'package' => $parts[1] ?? '',
55+
];
5356
}
5457

5558
protected $guarded = [];

app/Providers/HorizonServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function boot(): void
2828
protected function gate(): void
2929
{
3030
Gate::define('viewHorizon', function ($user = null) {
31-
return $user->isAdmin();
31+
return $user?->isAdmin() ?? false;
3232
});
3333
}
3434
}

app/Services/PluginSyncService.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ public function sync(Plugin $plugin): bool
6565

6666
if ($composerData) {
6767
if (isset($composerData['name']) && ! $plugin->name) {
68-
$updateData['name'] = $composerData['name'];
68+
$existing = Plugin::where('name', $composerData['name'])
69+
->where('id', '!=', $plugin->id)
70+
->exists();
71+
72+
if (! $existing) {
73+
$updateData['name'] = $composerData['name'];
74+
} else {
75+
Log::warning('[PluginSync] Plugin name already taken', [
76+
'plugin_id' => $plugin->id,
77+
'name' => $composerData['name'],
78+
]);
79+
}
6980
}
7081

7182
if (isset($composerData['description'])) {

app/Services/SatisService.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Services;
44

5+
use App\Enums\PluginType;
56
use App\Models\Plugin;
67
use Illuminate\Support\Facades\Http;
78
use Illuminate\Support\Facades\Log;
@@ -25,7 +26,7 @@ public function buildAll(?string $githubToken = null): array
2526
{
2627
$plugins = $this->getApprovedPlugins();
2728

28-
return $this->triggerBuild($plugins, $githubToken);
29+
return $this->triggerBuild($plugins, $githubToken, fullBuild: true);
2930
}
3031

3132
/**
@@ -107,6 +108,7 @@ protected function getApprovedPlugins(): array
107108
{
108109
return Plugin::query()
109110
->approved()
111+
->where('type', PluginType::Paid)
110112
->get()
111113
->map(fn (Plugin $plugin) => [
112114
'name' => $plugin->name,
@@ -120,7 +122,7 @@ protected function getApprovedPlugins(): array
120122
/**
121123
* @param array<int, array{name: string, repository_url: string, type: string, is_official?: bool}> $plugins
122124
*/
123-
protected function triggerBuild(array $plugins, ?string $githubToken = null): array
125+
protected function triggerBuild(array $plugins, ?string $githubToken = null, bool $fullBuild = false): array
124126
{
125127
if (! $this->apiUrl || ! $this->apiKey) {
126128
return [
@@ -139,7 +141,10 @@ protected function triggerBuild(array $plugins, ?string $githubToken = null): ar
139141
$githubToken ??= config('services.github.token');
140142

141143
try {
142-
$payload = ['plugins' => $plugins];
144+
$payload = [
145+
'plugins' => $plugins,
146+
'full_build' => $fullBuild,
147+
];
143148

144149
if ($githubToken) {
145150
$payload['github_token'] = $githubToken;

routes/web.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,19 @@
221221
}
222222
}
223223

224-
return to_route('docs.show', [
225-
'platform' => $platform,
226-
'version' => $version,
227-
'page' => $page,
228-
]);
224+
try {
225+
return to_route('docs.show', [
226+
'platform' => $platform,
227+
'version' => $version,
228+
'page' => $page,
229+
]);
230+
} catch (\Illuminate\Routing\Exceptions\UrlGenerationException) {
231+
return to_route('docs.show', [
232+
'platform' => $platform,
233+
'version' => $version,
234+
'page' => 'introduction',
235+
]);
236+
}
229237
})->name('docs')->where('page', '.*');
230238

231239
Route::get('order/{checkoutSessionId}', App\Livewire\OrderSuccess::class)->name('order.success');

tests/Feature/SatisSync/SatisSyncTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use App\Services\SatisService;
1010
use Illuminate\Foundation\Testing\RefreshDatabase;
1111
use Illuminate\Support\Facades\Bus;
12+
use Illuminate\Support\Facades\Http;
1213
use Livewire\Livewire;
1314
use Tests\TestCase;
1415

@@ -124,4 +125,29 @@ public function test_is_satis_synced_returns_true_when_synced(): void
124125

125126
$this->assertTrue($plugin->isSatisSynced());
126127
}
128+
129+
public function test_build_all_only_includes_paid_plugins(): void
130+
{
131+
Http::fake(['*' => Http::response(['job_id' => 'test-123', 'message' => 'Build started'], 200)]);
132+
133+
config(['services.satis.url' => 'https://satis.test', 'services.satis.api_key' => 'test-key']);
134+
135+
$paidPlugin = Plugin::factory()->paid()->approved()->create();
136+
Plugin::factory()->free()->approved()->create();
137+
138+
$service = new SatisService;
139+
$result = $service->buildAll();
140+
141+
$this->assertTrue($result['success']);
142+
$this->assertEquals(1, $result['plugins_count']);
143+
144+
Http::assertSent(function ($request) use ($paidPlugin) {
145+
$data = $request->data();
146+
$plugins = $data['plugins'] ?? [];
147+
148+
return count($plugins) === 1
149+
&& $plugins[0]['name'] === $paidPlugin->name
150+
&& $data['full_build'] === true;
151+
});
152+
}
127153
}

0 commit comments

Comments
 (0)