Skip to content

Commit

Permalink
Only send verify OR manage subscription email to new subscribers #22
Browse files Browse the repository at this point in the history
  • Loading branch information
sedan07 committed Feb 8, 2021
1 parent b797f36 commit a76e7c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/Http/Controllers/SubscribeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ public function postSubscribe()
->withErrors($e->getMessageBag());
}

// Send the subscriber a link to manage their subscription.
$subscription->notify(new ManageSubscriptionNotification());
if ($verified) {
// Send the subscriber a link to manage their subscription.
$subscription->notify(new ManageSubscriptionNotification());
}

return redirect()->back()->withSuccess(
sprintf(
Expand Down
5 changes: 5 additions & 0 deletions tests/SmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Notification;
use CachetHQ\Cachet\Notifications\Subscriber\VerifySubscriptionNotification;
use CachetHQ\Cachet\Notifications\Subscriber\ManageSubscriptionNotification;
use CachetHQ\Cachet\Models\Subscriber;
use Illuminate\Support\Facades\URL;

Expand Down Expand Up @@ -69,6 +70,10 @@ public function test_subscribe_page()
[$subscriber],
VerifySubscriptionNotification::class
);
Notification::assertNotSentTo(
[$subscriber],
ManageSubscriptionNotification::class
);

$verify_route = URL::signedRoute(cachet_route_generator('subscribe.verify'), ['code' => $subscriber->verify_code]);

Expand Down

0 comments on commit a76e7c3

Please sign in to comment.