]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Tag.php
The item table is now completely removed
[friendica.git] / src / Model / Tag.php
index 4371a6e46ac6d597b01e1223b674fdfb5441ef1b..c63ba0a83940e281b20066424f2082858972474a 100644 (file)
@@ -407,7 +407,7 @@ class Tag
 
                $searchpath = DI::baseUrl() . "/search?tag=";
 
-               $taglist = DBA::select('tag-view', ['type', 'name', 'url'],
+               $taglist = DBA::select('tag-view', ['type', 'name', 'url', 'cid'],
                        ['uri-id' => $item['uri-id'], 'type' => [self::HASHTAG, self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION]]);
                while ($tag = DBA::fetch($taglist)) {
                        if ($tag['url'] == '') {
@@ -428,7 +428,11 @@ class Tag
                                        break;
                                case self::MENTION:
                                case self::EXCLUSIVE_MENTION:
+                                       if (!empty($tag['cid'])) {
+                                               $tag['url'] = Contact::magicLinkById($tag['cid']);
+                                       } else {
                                                $tag['url'] = Contact::magicLink($tag['url']);
+                                       }
                                        $return['mentions'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a>';
                                        $return['tags'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a>';
                                        break;
@@ -452,7 +456,7 @@ class Tag
        public static function countByTag(string $search, int $uid = 0)
        {
                $condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))
-                       AND `uri-id` IN (SELECT `uri-id` FROM `item` WHERE `network` IN (?, ?, ?, ?))",
+                       AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
                        $search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
                $params = ['group_by' => ['uri-id']];
 
@@ -472,7 +476,7 @@ class Tag
        public static function getURIIdListByTag(string $search, int $uid = 0, int $start = 0, int $limit = 100, int $last_uriid = 0)
        {
                $condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))
-                       AND `uri-id` IN (SELECT `uri-id` FROM `item` WHERE `network` IN (?, ?, ?, ?))",
+                       AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
                        $search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
 
                if (!empty($last_uriid)) {