]> git.mxchange.org Git - friendica.git/commitdiff
Normalize the mentions and ensure to not have duplicates
authorMichael <heluecht@pirati.ca>
Tue, 2 Oct 2018 09:04:32 +0000 (09:04 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 2 Oct 2018 09:04:32 +0000 (09:04 +0000)
src/Model/Term.php

index fb7670a3066276ab05012718f72f0c2231255261..6042091c9b085b2cb4b57093f309de962242b002 100644 (file)
@@ -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']]);