X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FProtocol%2FDiaspora.php;h=77ad0170442359a5cac8a6bf3dc27898f194d7e7;hb=758444a7d29feec4944626abd3fc3007ae2964ef;hp=34bdf2e876bf16dfe6d37b85f42ccd664280ce5f;hpb=6e7ca479d63d9740c83074cd95b454da0c686885;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 34bdf2e876..77ad017044 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -10,6 +10,7 @@ namespace Friendica\Protocol; +use Friendica\Content\Feature; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Markdown; use Friendica\Core\Cache; @@ -3666,6 +3667,20 @@ class Diaspora return $msg; } + private static function prependParentAuthorMention($body, $profile_url) + { + $profile = Contact::getDetailsByURL($profile_url); + if (!empty($profile['addr']) + && $profile['contact-type'] != Contact::TYPE_COMMUNITY + && !strstr($body, $profile['addr']) + && !strstr($body, $profile_url) + ) { + $body = '@[url=' . $profile_url . ']' . $profile['nick'] . '[/url] ' . $body; + } + + return $body; + } + /** * @brief Sends a post * @@ -3773,12 +3788,18 @@ class Diaspora return $result; } - $parent = Item::selectFirst(['guid'], ['id' => $item["parent"], 'parent' => $item["parent"]]); + $parent = Item::selectFirst(['guid', 'author-link'], ['id' => $item["parent"], 'parent' => $item["parent"]]); if (!DBA::isResult($parent)) { return false; } - $text = html_entity_decode(BBCode::toMarkdown($item["body"])); + $body = $item["body"]; + + if (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions')) { + $body = self::prependParentAuthorMention($body, $parent['author-link']); + } + + $text = html_entity_decode(BBCode::toMarkdown($body)); $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM); $comment = ["author" => self::myHandle($owner),