+
{{ trans('settings.users_edit_profile') }}
{{ trans('preferences.profile_overview_desc') }}
diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.php
index 88cdbd890..f5d9c328d 100644
--- a/resources/views/vendor/notifications/email.blade.php
+++ b/resources/views/vendor/notifications/email.blade.php
@@ -159,7 +159,7 @@ $style = [
- {{ trans('common.email_action_help', ['actionText' => $actionText]) }}
+ {{ trans('common.email_action_help', ['actionText' => $actionText], $language) }}
@@ -187,7 +187,7 @@ $style = [
© {{ date('Y') }}
{{ setting('app-name') }}.
- {{ trans('common.email_rights') }}
+ {{ trans('common.email_rights', [], $language) }}
|
diff --git a/tests/Activity/WatchTest.php b/tests/Activity/WatchTest.php
index fd86029d3..fa50d8c79 100644
--- a/tests/Activity/WatchTest.php
+++ b/tests/Activity/WatchTest.php
@@ -2,12 +2,17 @@
namespace Tests\Activity;
+use BookStack\Activity\ActivityType;
+use BookStack\Activity\Models\Comment;
+use BookStack\Activity\Notifications\Messages\BaseActivityNotification;
use BookStack\Activity\Notifications\Messages\CommentCreationNotification;
use BookStack\Activity\Notifications\Messages\PageCreationNotification;
use BookStack\Activity\Notifications\Messages\PageUpdateNotification;
+use BookStack\Activity\Tools\ActivityLogger;
use BookStack\Activity\Tools\UserEntityWatchOptions;
use BookStack\Activity\WatchLevels;
use BookStack\Entities\Models\Entity;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Settings\UserNotificationPreferences;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
@@ -253,7 +258,7 @@ class WatchTest extends TestCase
$notifications->assertSentTo($editor, function (CommentCreationNotification $notification) use ($editor, $admin, $entities) {
$mail = $notification->toMail($editor);
- $mailContent = html_entity_decode(strip_tags($mail->render()));
+ $mailContent = html_entity_decode(strip_tags($mail->render()), ENT_QUOTES);
return $mail->subject === 'New comment on page: ' . $entities['page']->getShortName()
&& str_contains($mailContent, 'View Comment')
&& str_contains($mailContent, 'Page Name: ' . $entities['page']->name)
@@ -276,7 +281,7 @@ class WatchTest extends TestCase
$notifications->assertSentTo($editor, function (PageUpdateNotification $notification) use ($editor, $admin) {
$mail = $notification->toMail($editor);
- $mailContent = html_entity_decode(strip_tags($mail->render()));
+ $mailContent = html_entity_decode(strip_tags($mail->render()), ENT_QUOTES);
return $mail->subject === 'Updated page: Updated page'
&& str_contains($mailContent, 'View Page')
&& str_contains($mailContent, 'Page Name: Updated page')
@@ -305,7 +310,7 @@ class WatchTest extends TestCase
$notifications->assertSentTo($editor, function (PageCreationNotification $notification) use ($editor, $admin) {
$mail = $notification->toMail($editor);
- $mailContent = html_entity_decode(strip_tags($mail->render()));
+ $mailContent = html_entity_decode(strip_tags($mail->render()), ENT_QUOTES);
return $mail->subject === 'New page: My new page'
&& str_contains($mailContent, 'View Page')
&& str_contains($mailContent, 'Page Name: My new page')
@@ -313,6 +318,43 @@ class WatchTest extends TestCase
});
}
+ public function test_notifications_sent_in_right_language()
+ {
+ $editor = $this->users->editor();
+ $admin = $this->users->admin();
+ setting()->putUser($editor, 'language', 'de');
+ $entities = $this->entities->createChainBelongingToUser($editor);
+ $watches = new UserEntityWatchOptions($editor, $entities['book']);
+ $watches->updateLevelByValue(WatchLevels::COMMENTS);
+
+ $activities = [
+ ActivityType::PAGE_CREATE => $entities['page'],
+ ActivityType::PAGE_UPDATE => $entities['page'],
+ ActivityType::COMMENT_CREATE => (new Comment([]))->forceFill(['entity_id' => $entities['page']->id, 'entity_type' => $entities['page']->getMorphClass()]),
+ ];
+
+ $notifications = Notification::fake();
+ $logger = app()->make(ActivityLogger::class);
+ $this->actingAs($admin);
+
+ foreach ($activities as $activityType => $detail) {
+ $logger->add($activityType, $detail);
+ }
+
+ $sent = $notifications->sentNotifications()[get_class($editor)][$editor->id];
+ $this->assertCount(3, $sent);
+
+ foreach ($sent as $notificationInfo) {
+ $notification = $notificationInfo[0]['notification'];
+ $this->assertInstanceOf(BaseActivityNotification::class, $notification);
+ $mail = $notification->toMail($editor);
+ $mailContent = html_entity_decode(strip_tags($mail->render()), ENT_QUOTES);
+ $this->assertStringContainsString('Name der Seite:', $mailContent);
+ $this->assertStringContainsString('Diese Benachrichtigung wurde', $mailContent);
+ $this->assertStringContainsString('Sollte es beim Anklicken der Schaltfläche', $mailContent);
+ }
+ }
+
public function test_notifications_not_sent_if_lacking_view_permission_for_related_item()
{
$notifications = Notification::fake();
@@ -329,4 +371,32 @@ class WatchTest extends TestCase
$notifications->assertNothingSentTo($editor);
}
+
+ public function test_watches_deleted_on_user_delete()
+ {
+ $editor = $this->users->editor();
+ $page = $this->entities->page();
+
+ $watches = new UserEntityWatchOptions($editor, $page);
+ $watches->updateLevelByValue(WatchLevels::COMMENTS);
+ $this->assertDatabaseHas('watches', ['user_id' => $editor->id]);
+
+ $this->asAdmin()->delete($editor->getEditUrl());
+
+ $this->assertDatabaseMissing('watches', ['user_id' => $editor->id]);
+ }
+
+ public function test_watches_deleted_on_item_delete()
+ {
+ $editor = $this->users->editor();
+ $page = $this->entities->page();
+
+ $watches = new UserEntityWatchOptions($editor, $page);
+ $watches->updateLevelByValue(WatchLevels::COMMENTS);
+ $this->assertDatabaseHas('watches', ['watchable_type' => 'page', 'watchable_id' => $page->id]);
+
+ $this->entities->destroy($page);
+
+ $this->assertDatabaseMissing('watches', ['watchable_type' => 'page', 'watchable_id' => $page->id]);
+ }
}
diff --git a/tests/Helpers/EntityProvider.php b/tests/Helpers/EntityProvider.php
index ddc854290..3cb8c44d3 100644
--- a/tests/Helpers/EntityProvider.php
+++ b/tests/Helpers/EntityProvider.php
@@ -11,6 +11,7 @@ use BookStack\Entities\Repos\BookRepo;
use BookStack\Entities\Repos\BookshelfRepo;
use BookStack\Entities\Repos\ChapterRepo;
use BookStack\Entities\Repos\PageRepo;
+use BookStack\Entities\Tools\TrashCan;
use BookStack\Users\Models\User;
use Illuminate\Database\Eloquent\Builder;
@@ -197,6 +198,16 @@ class EntityProvider
return $draftPage;
}
+ /**
+ * Fully destroy the given entity from the system, bypassing the recycle bin
+ * stage. Still runs through main app deletion logic.
+ */
+ public function destroy(Entity $entity)
+ {
+ $trash = app()->make(TrashCan::class);
+ $trash->destroyEntity($entity);
+ }
+
/**
* @param Entity|Entity[] $entities
*/
diff --git a/tests/User/UserPreferencesTest.php b/tests/User/UserPreferencesTest.php
index 9d72f4e14..1b16b0b45 100644
--- a/tests/User/UserPreferencesTest.php
+++ b/tests/User/UserPreferencesTest.php
@@ -124,6 +124,23 @@ class UserPreferencesTest extends TestCase
$resp->assertDontSee('All Page Updates & Comments');
}
+ public function test_notification_preferences_dont_error_on_deleted_items()
+ {
+ $editor = $this->users->editor();
+ $book = $this->entities->book();
+
+ $options = new UserEntityWatchOptions($editor, $book);
+ $options->updateLevelByValue(WatchLevels::COMMENTS);
+
+ $this->actingAs($editor)->delete($book->getUrl());
+ $book->refresh();
+ $this->assertNotNull($book->deleted_at);
+
+ $resp = $this->actingAs($editor)->get('/preferences/notifications');
+ $resp->assertOk();
+ $resp->assertDontSee($book->name);
+ }
+
public function test_notification_preferences_not_accessible_to_guest()
{
$this->setSettings(['app-public' => 'true']);