Skip to content

Commit 4de5a2d

Browse files
committed
Merge branch 'development' into release
2 parents 27bf429 + 2abbcf5 commit 4de5a2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+591
-414
lines changed

.github/translators.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,5 @@ Flip333 :: German Informal; German
355355
Paulo Henrique (paulohsantos114) :: Portuguese, Brazilian
356356
Dženan (Dzenan) :: Swedish
357357
Péter Péli (peter.peli) :: Hungarian
358+
TWME :: Chinese Traditional
359+
Sascha (Man-in-Black) :: German

app/Activity/Notifications/MessageParts/LinkedMailMessageLine.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace BookStack\Activity\Notifications\MessageParts;
44

55
use Illuminate\Contracts\Support\Htmlable;
6+
use Stringable;
67

78
/**
89
* A line of text with linked text included, intended for use
910
* in MailMessages. The line should have a ':link' placeholder for
1011
* where the link should be inserted within the line.
1112
*/
12-
class LinkedMailMessageLine implements Htmlable
13+
class LinkedMailMessageLine implements Htmlable, Stringable
1314
{
1415
public function __construct(
1516
protected string $url,
@@ -23,4 +24,10 @@ public function toHtml(): string
2324
$link = '<a href="' . e($this->url) . '">' . e($this->linkText) . '</a>';
2425
return str_replace(':link', $link, e($this->line));
2526
}
27+
28+
public function __toString(): string
29+
{
30+
$link = "{$this->linkText} ({$this->url})";
31+
return str_replace(':link', $link, $this->line);
32+
}
2633
}

app/Activity/Notifications/MessageParts/ListMessageLine.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace BookStack\Activity\Notifications\MessageParts;
44

55
use Illuminate\Contracts\Support\Htmlable;
6+
use Stringable;
67

78
/**
89
* A bullet point list of content, where the keys of the given list array
910
* are bolded header elements, and the values follow.
1011
*/
11-
class ListMessageLine implements Htmlable
12+
class ListMessageLine implements Htmlable, Stringable
1213
{
1314
public function __construct(
1415
protected array $list
@@ -23,4 +24,13 @@ public function toHtml(): string
2324
}
2425
return implode("<br>\n", $list);
2526
}
27+
28+
public function __toString(): string
29+
{
30+
$list = [];
31+
foreach ($this->list as $header => $content) {
32+
$list[] = $header . ' ' . $content;
33+
}
34+
return implode("\n", $list);
35+
}
2636
}

app/Activity/Notifications/Messages/BaseActivityNotification.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
use BookStack\Activity\Models\Loggable;
66
use BookStack\Activity\Notifications\MessageParts\LinkedMailMessageLine;
7+
use BookStack\Notifications\MailNotification;
78
use BookStack\Users\Models\User;
89
use Illuminate\Bus\Queueable;
9-
use Illuminate\Notifications\Messages\MailMessage;
10-
use Illuminate\Notifications\Notification;
1110

12-
abstract class BaseActivityNotification extends Notification
11+
abstract class BaseActivityNotification extends MailNotification
1312
{
1413
use Queueable;
1514

@@ -19,22 +18,6 @@ public function __construct(
1918
) {
2019
}
2120

22-
/**
23-
* Get the notification's delivery channels.
24-
*
25-
* @param mixed $notifiable
26-
* @return array
27-
*/
28-
public function via($notifiable)
29-
{
30-
return ['mail'];
31-
}
32-
33-
/**
34-
* Get the mail representation of the notification.
35-
*/
36-
abstract public function toMail(mixed $notifiable): MailMessage;
37-
3821
/**
3922
* Get the array representation of the notification.
4023
*
@@ -52,12 +35,12 @@ public function toArray($notifiable)
5235
/**
5336
* Build the common reason footer line used in mail messages.
5437
*/
55-
protected function buildReasonFooterLine(): LinkedMailMessageLine
38+
protected function buildReasonFooterLine(string $language): LinkedMailMessageLine
5639
{
5740
return new LinkedMailMessageLine(
5841
url('/preferences/notifications'),
59-
trans('notifications.footer_reason'),
60-
trans('notifications.footer_reason_link'),
42+
trans('notifications.footer_reason', [], $language),
43+
trans('notifications.footer_reason_link', [], $language),
6144
);
6245
}
6346
}

app/Activity/Notifications/Messages/CommentCreationNotification.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@
55
use BookStack\Activity\Models\Comment;
66
use BookStack\Activity\Notifications\MessageParts\ListMessageLine;
77
use BookStack\Entities\Models\Page;
8+
use BookStack\Users\Models\User;
89
use Illuminate\Notifications\Messages\MailMessage;
910

1011
class CommentCreationNotification extends BaseActivityNotification
1112
{
12-
public function toMail(mixed $notifiable): MailMessage
13+
public function toMail(User $notifiable): MailMessage
1314
{
1415
/** @var Comment $comment */
1516
$comment = $this->detail;
1617
/** @var Page $page */
1718
$page = $comment->entity;
1819

19-
return (new MailMessage())
20-
->subject(trans('notifications.new_comment_subject', ['pageName' => $page->getShortName()]))
21-
->line(trans('notifications.new_comment_intro', ['appName' => setting('app-name')]))
20+
$language = $notifiable->getLanguage();
21+
22+
return $this->newMailMessage($language)
23+
->subject(trans('notifications.new_comment_subject', ['pageName' => $page->getShortName()], $language))
24+
->line(trans('notifications.new_comment_intro', ['appName' => setting('app-name')], $language))
2225
->line(new ListMessageLine([
23-
trans('notifications.detail_page_name') => $page->name,
24-
trans('notifications.detail_commenter') => $this->user->name,
25-
trans('notifications.detail_comment') => strip_tags($comment->html),
26+
trans('notifications.detail_page_name', [], $language) => $page->name,
27+
trans('notifications.detail_commenter', [], $language) => $this->user->name,
28+
trans('notifications.detail_comment', [], $language) => strip_tags($comment->html),
2629
]))
27-
->action(trans('notifications.action_view_comment'), $page->getUrl('#comment' . $comment->local_id))
28-
->line($this->buildReasonFooterLine());
30+
->action(trans('notifications.action_view_comment', [], $language), $page->getUrl('#comment' . $comment->local_id))
31+
->line($this->buildReasonFooterLine($language));
2932
}
3033
}

app/Activity/Notifications/Messages/PageCreationNotification.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@
44

55
use BookStack\Activity\Notifications\MessageParts\ListMessageLine;
66
use BookStack\Entities\Models\Page;
7+
use BookStack\Users\Models\User;
78
use Illuminate\Notifications\Messages\MailMessage;
89

910
class PageCreationNotification extends BaseActivityNotification
1011
{
11-
public function toMail(mixed $notifiable): MailMessage
12+
public function toMail(User $notifiable): MailMessage
1213
{
1314
/** @var Page $page */
1415
$page = $this->detail;
1516

16-
return (new MailMessage())
17-
->subject(trans('notifications.new_page_subject', ['pageName' => $page->getShortName()]))
18-
->line(trans('notifications.new_page_intro', ['appName' => setting('app-name')]))
17+
$language = $notifiable->getLanguage();
18+
19+
return $this->newMailMessage($language)
20+
->subject(trans('notifications.new_page_subject', ['pageName' => $page->getShortName()], $language))
21+
->line(trans('notifications.new_page_intro', ['appName' => setting('app-name')], $language))
1922
->line(new ListMessageLine([
20-
trans('notifications.detail_page_name') => $page->name,
21-
trans('notifications.detail_created_by') => $this->user->name,
23+
trans('notifications.detail_page_name', [], $language) => $page->name,
24+
trans('notifications.detail_created_by', [], $language) => $this->user->name,
2225
]))
23-
->action(trans('notifications.action_view_page'), $page->getUrl())
24-
->line($this->buildReasonFooterLine());
26+
->action(trans('notifications.action_view_page', [], $language), $page->getUrl())
27+
->line($this->buildReasonFooterLine($language));
2528
}
2629
}

app/Activity/Notifications/Messages/PageUpdateNotification.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@
44

55
use BookStack\Activity\Notifications\MessageParts\ListMessageLine;
66
use BookStack\Entities\Models\Page;
7+
use BookStack\Users\Models\User;
78
use Illuminate\Notifications\Messages\MailMessage;
89

910
class PageUpdateNotification extends BaseActivityNotification
1011
{
11-
public function toMail(mixed $notifiable): MailMessage
12+
public function toMail(User $notifiable): MailMessage
1213
{
1314
/** @var Page $page */
1415
$page = $this->detail;
1516

16-
return (new MailMessage())
17-
->subject(trans('notifications.updated_page_subject', ['pageName' => $page->getShortName()]))
18-
->line(trans('notifications.updated_page_intro', ['appName' => setting('app-name')]))
17+
$language = $notifiable->getLanguage();
18+
19+
return $this->newMailMessage($language)
20+
->subject(trans('notifications.updated_page_subject', ['pageName' => $page->getShortName()], $language))
21+
->line(trans('notifications.updated_page_intro', ['appName' => setting('app-name')], $language))
1922
->line(new ListMessageLine([
20-
trans('notifications.detail_page_name') => $page->name,
21-
trans('notifications.detail_updated_by') => $this->user->name,
23+
trans('notifications.detail_page_name', [], $language) => $page->name,
24+
trans('notifications.detail_updated_by', [], $language) => $this->user->name,
2225
]))
23-
->line(trans('notifications.updated_page_debounce'))
24-
->action(trans('notifications.action_view_page'), $page->getUrl())
25-
->line($this->buildReasonFooterLine());
26+
->line(trans('notifications.updated_page_debounce', [], $language))
27+
->action(trans('notifications.action_view_page', [], $language), $page->getUrl())
28+
->line($this->buildReasonFooterLine($language));
2629
}
2730
}

app/Entities/EntityProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct()
3737
* Fetch all core entity types as an associated array
3838
* with their basic names as the keys.
3939
*
40-
* @return array<Entity>
40+
* @return array<string, Entity>
4141
*/
4242
public function all(): array
4343
{

app/Entities/Models/Entity.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use BookStack\Activity\Models\Tag;
1111
use BookStack\Activity\Models\View;
1212
use BookStack\Activity\Models\Viewable;
13+
use BookStack\Activity\Models\Watch;
1314
use BookStack\App\Model;
1415
use BookStack\App\Sluggable;
1516
use BookStack\Entities\Tools\SlugGenerator;
@@ -330,6 +331,14 @@ public function isFavourite(): bool
330331
->exists();
331332
}
332333

334+
/**
335+
* Get the related watches for this entity.
336+
*/
337+
public function watches(): MorphMany
338+
{
339+
return $this->morphMany(Watch::class, 'watchable');
340+
}
341+
333342
/**
334343
* {@inheritdoc}
335344
*/

app/Entities/Tools/TrashCan.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ protected function destroyCommonRelations(Entity $entity)
376376
$entity->searchTerms()->delete();
377377
$entity->deletions()->delete();
378378
$entity->favourites()->delete();
379+
$entity->watches()->delete();
379380
$entity->referencesTo()->delete();
380381
$entity->referencesFrom()->delete();
381382

0 commit comments

Comments
 (0)