From: Michael Date: Tue, 2 Oct 2018 09:04:32 +0000 (+0000) Subject: Normalize the mentions and ensure to not have duplicates X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fcfd04bcc9813e3bb59fa73765f1687cfa2bb978;p=friendica.git Normalize the mentions and ensure to not have duplicates --- diff --git a/src/Model/Term.php b/src/Model/Term.php index fb7670a306..6042091c9b 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -130,12 +130,26 @@ class Term $term = substr($tag, 1); } elseif (substr(trim($tag), 0, 1) == '@') { $type = TERM_MENTION; - $term = substr($tag, 1); + + $contact = Contact::getDetailsByURL($link, 0); + if (!empty($contact['name'])) { + $term = $contact['name']; + } else { + $term = substr($tag, 1); + } + + if (!empty($contact['url'])) { + $link = $contact['url']; + } } else { // This shouldn't happen $type = TERM_HASHTAG; $term = $tag; } + if (DBA::exists('term', ['uid' => $message['uid'], 'otype' => TERM_OBJ_POST, 'oid' => $itemid, 'url' => $link])) { + continue; + } + if ($message['uid'] == 0) { $global = true; DBA::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);