[COMPONENT][Link] Ignore html anchors that include mention class

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-24 17:35:32 +00:00
parent 0d5e545a6e
commit 36483a6ecd
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 4 additions and 3 deletions

View File

@ -41,7 +41,8 @@ class Link extends Component
{
if (Common::config('attachments', 'process_links')) {
$matched_urls = [];
preg_match_all($this->getURLRegex(), $content, $matched_urls);
// TODO: This solution to ignore mentions when content is in html is far from ideal
preg_match_all($this->getURLRegex(), preg_replace('#<a href="(.*?)" class="u-url mention">#', '', $content), $matched_urls);
$matched_urls = array_unique($matched_urls[1]);
foreach ($matched_urls as $match) {
try {

View File

@ -90,7 +90,7 @@ class Note extends Model
{
$handleInReplyTo = function (AbstractObject|string $type_note): ?int {
try {
$parent_note = is_null($type_note->get('inReplyTo')) ? null : ActivityPub::getObjectByUri($type_note->get('inReplyTo'), try_online: true);
$parent_note = \is_null($type_note->get('inReplyTo')) ? null : ActivityPub::getObjectByUri($type_note->get('inReplyTo'), try_online: true);
if ($parent_note instanceof \App\Entity\Note) {
return $parent_note->getId();
} elseif ($parent_note instanceof Type\AbstractObject && $parent_note->get('type') === 'Note') {
@ -201,7 +201,7 @@ class Note extends Model
Conversation::assignLocalConversation($obj, $reply_to);
// Need file and note ids for the next step
Event::handle('ProcessNoteContent', [$obj, $obj->getContent(), $obj->getContentType(), $process_note_content_extra_args = []]);
Event::handle('ProcessNoteContent', [$obj, $obj->getRendered(), $obj->getContentType(), $process_note_content_extra_args = []]);
if ($processed_attachments !== []) {
foreach ($processed_attachments as [$a, $fname]) {