diff --git a/app/Access/EmailConfirmationService.php b/app/Access/EmailConfirmationService.php index 79220f996..de9ea69b8 100644 --- a/app/Access/EmailConfirmationService.php +++ b/app/Access/EmailConfirmationService.php @@ -2,8 +2,8 @@ namespace BookStack\Access; +use BookStack\Access\Notifications\ConfirmEmailNotification; use BookStack\Exceptions\ConfirmationEmailException; -use BookStack\Notifications\ConfirmEmail; use BookStack\Users\Models\User; class EmailConfirmationService extends UserTokenService @@ -26,7 +26,7 @@ class EmailConfirmationService extends UserTokenService $this->deleteByUser($user); $token = $this->createTokenForUser($user); - $user->notify(new ConfirmEmail($token)); + $user->notify(new ConfirmEmailNotification($token)); } /** diff --git a/app/Notifications/ConfirmEmail.php b/app/Access/Notifications/ConfirmEmailNotification.php similarity index 82% rename from app/Notifications/ConfirmEmail.php rename to app/Access/Notifications/ConfirmEmailNotification.php index 6b395e137..c67e1cf62 100644 --- a/app/Notifications/ConfirmEmail.php +++ b/app/Access/Notifications/ConfirmEmailNotification.php @@ -1,11 +1,12 @@ deleteByUser($user); $token = $this->createTokenForUser($user); - $user->notify(new UserInvite($token)); + $user->notify(new UserInviteNotification($token)); } } diff --git a/app/Activity/Notifications/Messages/BaseActivityNotification.php b/app/Activity/Notifications/Messages/BaseActivityNotification.php index a2045c8dc..414859091 100644 --- a/app/Activity/Notifications/Messages/BaseActivityNotification.php +++ b/app/Activity/Notifications/Messages/BaseActivityNotification.php @@ -4,7 +4,7 @@ namespace BookStack\Activity\Notifications\Messages; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Notifications\MessageParts\LinkedMailMessageLine; -use BookStack\Notifications\MailNotification; +use BookStack\App\MailNotification; use BookStack\Users\Models\User; use Illuminate\Bus\Queueable; diff --git a/app/Notifications/MailNotification.php b/app/App/MailNotification.php similarity index 96% rename from app/Notifications/MailNotification.php rename to app/App/MailNotification.php index 1f40219f9..8c57b5621 100644 --- a/app/Notifications/MailNotification.php +++ b/app/App/MailNotification.php @@ -1,6 +1,6 @@ logActivity(ActivityType::MAINTENANCE_ACTION_RUN, 'send-test-email'); try { - user()->notifyNow(new TestEmail()); + user()->notifyNow(new TestEmailNotification()); $this->showSuccessNotification(trans('settings.maint_send_test_email_success', ['address' => user()->email])); } catch (\Exception $exception) { $errorMessage = trans('errors.maintenance_test_email_failure') . "\n" . $exception->getMessage(); diff --git a/app/Notifications/TestEmail.php b/app/Settings/TestEmailNotification.php similarity index 78% rename from app/Notifications/TestEmail.php rename to app/Settings/TestEmailNotification.php index af9e5847f..3b13543e4 100644 --- a/app/Notifications/TestEmail.php +++ b/app/Settings/TestEmailNotification.php @@ -1,11 +1,12 @@ notify(new ResetPassword($token)); + $this->notify(new ResetPasswordNotification($token)); } /** diff --git a/tests/Api/UsersApiTest.php b/tests/Api/UsersApiTest.php index e2a04b528..6ad727257 100644 --- a/tests/Api/UsersApiTest.php +++ b/tests/Api/UsersApiTest.php @@ -2,11 +2,11 @@ namespace Tests\Api; +use BookStack\Access\Notifications\UserInviteNotification; use BookStack\Activity\ActivityType; use BookStack\Activity\Models\Activity as ActivityModel; use BookStack\Entities\Models\Entity; use BookStack\Facades\Activity; -use BookStack\Notifications\UserInvite; use BookStack\Users\Models\Role; use BookStack\Users\Models\User; use Illuminate\Support\Facades\Hash; @@ -140,7 +140,7 @@ class UsersApiTest extends TestCase $resp->assertStatus(200); /** @var User $user */ $user = User::query()->where('email', '=', 'bboris@example.com')->first(); - Notification::assertSentTo($user, UserInvite::class); + Notification::assertSentTo($user, UserInviteNotification::class); } public function test_create_name_and_email_validation() diff --git a/tests/Auth/RegistrationTest.php b/tests/Auth/RegistrationTest.php index bc190afd8..ff1a9d66b 100644 --- a/tests/Auth/RegistrationTest.php +++ b/tests/Auth/RegistrationTest.php @@ -2,7 +2,7 @@ namespace Tests\Auth; -use BookStack\Notifications\ConfirmEmail; +use BookStack\Access\Notifications\ConfirmEmailNotification; use BookStack\Users\Models\Role; use BookStack\Users\Models\User; use Illuminate\Support\Facades\DB; @@ -28,7 +28,7 @@ class RegistrationTest extends TestCase // Ensure notification sent /** @var User $dbUser */ $dbUser = User::query()->where('email', '=', $user->email)->first(); - Notification::assertSentTo($dbUser, ConfirmEmail::class); + Notification::assertSentTo($dbUser, ConfirmEmailNotification::class); // Test access and resend confirmation email $resp = $this->post('/login', ['email' => $user->email, 'password' => $user->password]); @@ -42,7 +42,7 @@ class RegistrationTest extends TestCase // Get confirmation and confirm notification matches $emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first(); - Notification::assertSentTo($dbUser, ConfirmEmail::class, function ($notification, $channels) use ($emailConfirmation) { + Notification::assertSentTo($dbUser, ConfirmEmailNotification::class, function ($notification, $channels) use ($emailConfirmation) { return $notification->token === $emailConfirmation->token; }); diff --git a/tests/Auth/ResetPasswordTest.php b/tests/Auth/ResetPasswordTest.php index b97a2f2d3..e60ac5643 100644 --- a/tests/Auth/ResetPasswordTest.php +++ b/tests/Auth/ResetPasswordTest.php @@ -2,7 +2,7 @@ namespace Tests\Auth; -use BookStack\Notifications\ResetPassword; +use BookStack\Access\Notifications\ResetPasswordNotification; use BookStack\Users\Models\User; use Illuminate\Support\Facades\Notification; use Tests\TestCase; @@ -34,8 +34,8 @@ class ResetPasswordTest extends TestCase /** @var User $user */ $user = User::query()->where('email', '=', 'admin@admin.com')->first(); - Notification::assertSentTo($user, ResetPassword::class); - $n = Notification::sent($user, ResetPassword::class); + Notification::assertSentTo($user, ResetPasswordNotification::class); + $n = Notification::sent($user, ResetPasswordNotification::class); $this->get('/password/reset/' . $n->first()->token) ->assertOk() @@ -95,7 +95,7 @@ class ResetPasswordTest extends TestCase $resp = $this->followingRedirects()->post('/password/email', [ 'email' => $editor->email, ]); - Notification::assertTimesSent(1, ResetPassword::class); + Notification::assertTimesSent(1, ResetPasswordNotification::class); $resp->assertSee('A password reset link will be sent to ' . $editor->email . ' if that email address is found in the system.'); } } diff --git a/tests/Auth/UserInviteTest.php b/tests/Auth/UserInviteTest.php index 8d6143877..a9dee0007 100644 --- a/tests/Auth/UserInviteTest.php +++ b/tests/Auth/UserInviteTest.php @@ -2,8 +2,8 @@ namespace Tests\Auth; +use BookStack\Access\Notifications\UserInviteNotification; use BookStack\Access\UserInviteService; -use BookStack\Notifications\UserInvite; use BookStack\Users\Models\User; use Carbon\Carbon; use Illuminate\Notifications\Messages\MailMessage; @@ -29,7 +29,7 @@ class UserInviteTest extends TestCase $newUser = User::query()->where('email', '=', $email)->orderBy('id', 'desc')->first(); - Notification::assertSentTo($newUser, UserInvite::class); + Notification::assertSentTo($newUser, UserInviteNotification::class); $this->assertDatabaseHas('user_invites', [ 'user_id' => $newUser->id, ]); @@ -50,7 +50,7 @@ class UserInviteTest extends TestCase $resp->assertRedirect('/settings/users'); $newUser = User::query()->where('email', '=', $email)->orderBy('id', 'desc')->first(); - Notification::assertSentTo($newUser, UserInvite::class, function ($notification, $channels, $notifiable) { + Notification::assertSentTo($newUser, UserInviteNotification::class, function ($notification, $channels, $notifiable) { /** @var MailMessage $mail */ $mail = $notification->toMail($notifiable); diff --git a/tests/Settings/TestEmailTest.php b/tests/Settings/TestEmailTest.php index 322f90107..e96024e7b 100644 --- a/tests/Settings/TestEmailTest.php +++ b/tests/Settings/TestEmailTest.php @@ -2,7 +2,7 @@ namespace Tests\Settings; -use BookStack\Notifications\TestEmail; +use BookStack\Settings\TestEmailNotification; use Illuminate\Contracts\Notifications\Dispatcher; use Illuminate\Support\Facades\Notification; use Tests\TestCase; @@ -26,7 +26,7 @@ class TestEmailTest extends TestCase $sendReq->assertRedirect('/settings/maintenance#image-cleanup'); $this->assertSessionHas('success', 'Email sent to ' . $admin->email); - Notification::assertSentTo($admin, TestEmail::class); + Notification::assertSentTo($admin, TestEmailNotification::class); } public function test_send_test_email_failure_displays_error_notification() @@ -57,6 +57,6 @@ class TestEmailTest extends TestCase $this->permissions->grantUserRolePermissions($user, ['settings-manage']); $sendReq = $this->actingAs($user)->post('/settings/maintenance/send-test-email'); - Notification::assertSentTo($user, TestEmail::class); + Notification::assertSentTo($user, TestEmailNotification::class); } }