Skip to content

Commit a7d8100

Browse files
simonhampclaude
andcommitted
Add new plugin notification opt-in and rename Plugin Directory to Plugin Marketplace
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3db7116 commit a7d8100

File tree

15 files changed

+277
-10
lines changed

15 files changed

+277
-10
lines changed

app/Livewire/Customer/Settings.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,25 @@ class Settings extends Component
2828

2929
public bool $receivesNotificationEmails = true;
3030

31+
public bool $receivesNewPluginNotifications = true;
32+
3133
public function mount(): void
3234
{
3335
$this->name = auth()->user()->name ?? '';
3436
$this->receivesNotificationEmails = auth()->user()->receives_notification_emails;
37+
$this->receivesNewPluginNotifications = auth()->user()->receives_new_plugin_notifications;
3538
}
3639

3740
public function updatedReceivesNotificationEmails(bool $value): void
3841
{
3942
auth()->user()->update(['receives_notification_emails' => $value]);
4043
}
4144

45+
public function updatedReceivesNewPluginNotifications(bool $value): void
46+
{
47+
auth()->user()->update(['receives_new_plugin_notifications' => $value]);
48+
}
49+
4250
public function updateName(): void
4351
{
4452
$this->validate([

app/Models/Plugin.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Enums\PluginTier;
88
use App\Enums\PluginType;
99
use App\Enums\PriceTier;
10+
use App\Notifications\NewPluginAvailable;
1011
use App\Notifications\PluginApproved;
1112
use App\Notifications\PluginRejected;
1213
use App\Services\PluginSyncService;
@@ -20,6 +21,7 @@
2021
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
2122
use Illuminate\Database\Eloquent\Relations\HasMany;
2223
use Illuminate\Database\Eloquent\Relations\HasOne;
24+
use Illuminate\Support\Facades\Notification;
2325

2426
class Plugin extends Model
2527
{
@@ -497,6 +499,7 @@ public function getRepositoryOwnerAndName(): ?array
497499
public function approve(int $approvedById): void
498500
{
499501
$previousStatus = $this->status;
502+
$isFirstApproval = $this->approved_at === null;
500503

501504
$this->update([
502505
'status' => PluginStatus::Approved,
@@ -515,6 +518,15 @@ public function approve(int $approvedById): void
515518

516519
$this->user->notify(new PluginApproved($this));
517520

521+
if ($isFirstApproval) {
522+
$recipients = User::query()
523+
->where('receives_new_plugin_notifications', true)
524+
->where('id', '!=', $this->user_id)
525+
->get();
526+
527+
Notification::send($recipients, new NewPluginAvailable($this));
528+
}
529+
518530
resolve(PluginSyncService::class)->sync($this);
519531
}
520532

app/Models/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ protected function casts(): array
359359
'email_verified_at' => 'datetime',
360360
'password' => 'hashed',
361361
'receives_notification_emails' => 'boolean',
362+
'receives_new_plugin_notifications' => 'boolean',
362363
'mobile_repo_access_granted_at' => 'datetime',
363364
'claude_plugins_repo_access_granted_at' => 'datetime',
364365
'discord_role_granted_at' => 'datetime',
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace App\Notifications;
4+
5+
use App\Models\Plugin;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Contracts\Queue\ShouldQueue;
8+
use Illuminate\Notifications\Messages\MailMessage;
9+
use Illuminate\Notifications\Notification;
10+
11+
class NewPluginAvailable extends Notification implements ShouldQueue
12+
{
13+
use Queueable;
14+
15+
public function __construct(
16+
public Plugin $plugin
17+
) {}
18+
19+
/**
20+
* @return array<int, string>
21+
*/
22+
public function via(object $notifiable): array
23+
{
24+
if (! $notifiable->receives_new_plugin_notifications) {
25+
return [];
26+
}
27+
28+
return ['mail', 'database'];
29+
}
30+
31+
public function toMail(object $notifiable): MailMessage
32+
{
33+
return (new MailMessage)
34+
->subject("New Plugin: {$this->plugin->name}")
35+
->greeting('A new plugin is available!')
36+
->line("**{$this->plugin->name}** has just been added to the NativePHP Plugin Marketplace.")
37+
->action('View Plugin', url('/plugins'))
38+
->line('You can manage your notification preferences in your account settings.');
39+
}
40+
41+
/**
42+
* @return array<string, mixed>
43+
*/
44+
public function toArray(object $notifiable): array
45+
{
46+
return [
47+
'title' => "New Plugin: {$this->plugin->name}",
48+
'body' => "{$this->plugin->name} has just been added to the NativePHP Plugin Marketplace.",
49+
'plugin_id' => $this->plugin->id,
50+
'plugin_name' => $this->plugin->name,
51+
];
52+
}
53+
}

app/Notifications/PluginApproved.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function toMail(object $notifiable): MailMessage
3434
return (new MailMessage)
3535
->subject('Your Plugin Has Been Approved!')
3636
->greeting('Great news!')
37-
->line("Your plugin **{$this->plugin->name}** has been approved and is now listed in the NativePHP Plugin Directory.")
38-
->action('View Plugin Directory', url('/plugins'))
37+
->line("Your plugin **{$this->plugin->name}** has been approved and is now listed in the NativePHP Plugin Marketplace.")
38+
->action('View Plugin Marketplace', url('/plugins'))
3939
->line('Thank you for contributing to the NativePHP ecosystem!');
4040
}
4141

@@ -48,7 +48,7 @@ public function toArray(object $notifiable): array
4848
{
4949
return [
5050
'title' => 'Your Plugin Has Been Approved!',
51-
'body' => "{$this->plugin->name} is now listed in the NativePHP Plugin Directory.",
51+
'body' => "{$this->plugin->name} is now listed in the NativePHP Plugin Marketplace.",
5252
'plugin_id' => $this->plugin->id,
5353
'plugin_name' => $this->plugin->name,
5454
];

app/Notifications/PluginRejected.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function toMail(object $notifiable): MailMessage
3434
return (new MailMessage)
3535
->subject('Plugin Submission Update')
3636
->greeting('Hello,')
37-
->line("Unfortunately, your plugin **{$this->plugin->name}** was not approved for the NativePHP Plugin Directory.")
37+
->line("Unfortunately, your plugin **{$this->plugin->name}** was not approved for the NativePHP Plugin Marketplace.")
3838
->line('**Reason:**')
3939
->line($this->plugin->rejection_reason)
4040
->action('View Your Plugins', route('customer.plugins.index'))
@@ -50,7 +50,7 @@ public function toArray(object $notifiable): array
5050
{
5151
return [
5252
'title' => 'Plugin Submission Update',
53-
'body' => "Your plugin {$this->plugin->name} was not approved for the NativePHP Plugin Directory.",
53+
'body' => "Your plugin {$this->plugin->name} was not approved for the NativePHP Plugin Marketplace.",
5454
'plugin_id' => $this->plugin->id,
5555
'plugin_name' => $this->plugin->name,
5656
'rejection_reason' => $this->plugin->rejection_reason,

database/factories/UserFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function definition(): array
2626
'password' => Hash::make('password'),
2727
'remember_token' => Str::random(10),
2828
'receives_notification_emails' => true,
29+
'receives_new_plugin_notifications' => true,
2930
];
3031
}
3132

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('users', function (Blueprint $table) {
15+
$table->boolean('receives_new_plugin_notifications')->default(true)->after('receives_notification_emails');
16+
});
17+
}
18+
19+
public function down(): void
20+
{
21+
Schema::table('users', function (Blueprint $table) {
22+
$table->dropColumn('receives_new_plugin_notifications');
23+
});
24+
}
25+
};

resources/views/customer/plugins/create.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</nav>
2525
<h1 class="mt-2 text-2xl font-bold text-gray-900 dark:text-white">Submit Your Plugin</h1>
2626
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
27-
Add your plugin to the NativePHP Plugin Directory
27+
Add your plugin to the NativePHP Plugin Marketplace
2828
</p>
2929
</div>
3030
<x-dashboard-menu />

resources/views/customer/plugins/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</div>
3737
<h3 class="mt-4 text-lg font-semibold text-gray-900 dark:text-white">Submit Your Plugin</h3>
3838
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">
39-
Built a plugin? Submit it to the NativePHP Plugin Directory and share it with the community.
39+
Built a plugin? Submit it to the NativePHP Plugin Marketplace and share it with the community.
4040
</p>
4141
<a href="{{ route('customer.plugins.create') }}" class="mt-4 inline-flex items-center rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:bg-indigo-500 dark:hover:bg-indigo-600">
4242
Submit a Plugin

0 commit comments

Comments
 (0)