mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-12-19 10:42:29 +03:00
- Added new user notification preference, opt-in by default - Added parser to extract mentions from comment HTML, with tests to cover. - Added notification and notification handling Not yet tested, needs testing coverage.
29 lines
647 B
PHP
29 lines
647 B
PHP
<?php
|
|
|
|
namespace BookStack\Activity\Tools;
|
|
|
|
use BookStack\Util\HtmlDocument;
|
|
use DOMElement;
|
|
|
|
class MentionParser
|
|
{
|
|
public function parseUserIdsFromHtml(string $html): array
|
|
{
|
|
$doc = new HtmlDocument($html);
|
|
|
|
$ids = [];
|
|
$mentionLinks = $doc->queryXPath('//a[@data-mention-user-id]');
|
|
|
|
foreach ($mentionLinks as $link) {
|
|
if ($link instanceof DOMElement) {
|
|
$id = intval($link->getAttribute('data-mention-user-id'));
|
|
if ($id > 0) {
|
|
$ids[] = $id;
|
|
}
|
|
}
|
|
}
|
|
|
|
return array_values(array_unique($ids));
|
|
}
|
|
}
|