Merge pull request #9507 from MrPetovan/bug/9480-never-mention-yourself

Never mention yourself
This commit is contained in:
Michael Vogel 2020-11-08 22:37:07 +01:00 committed by GitHub
commit d07b580366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -1258,7 +1258,7 @@ class Transmitter
return $match[0]; return $match[0];
} }
return '@[url=' . $data['url'] . ']' . $data['nick'] . '[/url]'; return '[url=' . $data['url'] . ']@' . $data['nick'] . '[/url]';
} }
/** /**
@ -1425,7 +1425,7 @@ class Transmitter
} }
if (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions')) { if (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions')) {
$body = self::prependMentions($body, $item['uri-id']); $body = self::prependMentions($body, $item['uri-id'], $item['author-link']);
} }
if ($type == 'Event') { if ($type == 'Event') {
@ -1973,7 +1973,7 @@ class Transmitter
return HTTPSignature::transmit($signed, $profile['inbox'], $uid); return HTTPSignature::transmit($signed, $profile['inbox'], $uid);
} }
private static function prependMentions($body, int $uriid) private static function prependMentions($body, int $uriid, string $authorLink)
{ {
$mentions = []; $mentions = [];
@ -1983,6 +1983,7 @@ class Transmitter
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY && $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr']) && !strstr($body, $profile['addr'])
&& !strstr($body, $tag['url']) && !strstr($body, $tag['url'])
&& $tag['url'] !== $authorLink
) { ) {
$mentions[] = '@[url=' . $tag['url'] . ']' . $profile['nick'] . '[/url]'; $mentions[] = '@[url=' . $tag['url'] . ']' . $profile['nick'] . '[/url]';
} }