Merge pull request #6717 from annando/network-mentions

Automatically adding mentions in the network stream hadn't really worked
This commit is contained in:
Hypolite Petovan 2019-02-21 21:14:23 -05:00 committed by GitHub
commit 2d91d5c3d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ use Friendica\Database\DBA;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Term; use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
@ -781,10 +782,12 @@ class Post extends BaseObject
{ {
$a = self::getApp(); $a = self::getApp();
if (!local_user() || empty($a->profile['addr'])) { if (!local_user()) {
return ''; return '';
} }
$owner = User::getOwnerDataById($a->user['uid']);
if (!Feature::isEnabled(local_user(), 'explicit_mentions')) { if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
return ''; return '';
} }
@ -795,7 +798,7 @@ class Post extends BaseObject
return ''; return '';
} }
if ($item['author-addr'] != $a->profile['addr']) { if ($item['author-addr'] != $owner['addr']) {
$text = '@' . $item['author-addr'] . ' '; $text = '@' . $item['author-addr'] . ' ';
} else { } else {
$text = ''; $text = '';
@ -805,8 +808,8 @@ class Post extends BaseObject
foreach ($terms as $term) { foreach ($terms as $term) {
$profile = Contact::getDetailsByURL($term['url']); $profile = Contact::getDetailsByURL($term['url']);
if (!empty($profile['addr']) && ($profile['contact-type'] != Contact::TYPE_COMMUNITY) && if (($profile['contact-type'] != Contact::TYPE_COMMUNITY) &&
($profile['addr'] != $a->profile['addr']) && !strstr($text, $profile['addr'])) { ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
$text .= '@' . $profile['addr'] . ' '; $text .= '@' . $profile['addr'] . ' ';
} }
} }