]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Fix the test data
[friendica.git] / include / api.php
index 31cffc180bc4752842d66b2c5e41e61b0574f8c4..4aa4b21e29199e4a0c339cb884d94b251f2062fd 100644 (file)
@@ -1964,12 +1964,12 @@ function api_conversation_show($type)
        Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
 
        // try to fetch the item for the local user - or the public item, if there is no local one
-       $item = Post::selectFirst(['parent-uri'], ['id' => $id]);
+       $item = Post::selectFirst(['parent-uri-id'], ['id' => $id]);
        if (!DBA::isResult($item)) {
                throw new BadRequestException("There is no status with this id.");
        }
 
-       $parent = Post::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
+       $parent = Post::selectFirst(['id'], ['uri-id' => $item['parent-uri-id'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
        if (!DBA::isResult($parent)) {
                throw new BadRequestException("There is no status with this id.");
        }
@@ -2041,9 +2041,9 @@ function api_statuses_repeat($type)
        Logger::log('API: api_statuses_repeat: '.$id);
 
        $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
-       $item = Item::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
-
-       if (DBA::isResult($item) && $item['body'] != "") {
+       $item = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
+       if (DBA::isResult($item) && !empty($item['body'])) {
                if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) {
                        if (!Item::performActivity($id, 'announce', local_user())) {
                                throw new InternalServerErrorException();
@@ -2171,17 +2171,17 @@ function api_statuses_mentions($type)
 
        $start = max(0, ($page - 1) * $count);
 
+       $query = "`gravity` IN (?, ?) AND `id` IN (SELECT `iid` FROM `user-item`                
+               WHERE (`hidden` IS NULL OR NOT `hidden`) AND
+                       `uid` = ? AND `notification-type` & ? != 0
+                       AND `iid` > ?";
+
        $condition = [GRAVITY_PARENT, GRAVITY_COMMENT, api_user(),
                UserItem::NOTIF_EXPLICIT_TAGGED | UserItem::NOTIF_IMPLICIT_TAGGED |
                UserItem::NOTIF_THREAD_COMMENT | UserItem::NOTIF_DIRECT_COMMENT |
                UserItem::NOTIF_DIRECT_THREAD_COMMENT,
                $since_id];
 
-       $query = "`gravity` IN (?, ?) AND `id` IN (SELECT `iid` FROM `user-item`                
-               WHERE (`hidden` IS NULL OR NOT `hidden`) AND
-                       `uid` = ? AND `notification-type` & ? != 0
-                       AND `iid` > ?";
-
        if ($max_id > 0) {
                $query .= " AND `iid` <= ?";
                $condition[] = $max_id;
@@ -2189,7 +2189,7 @@ function api_statuses_mentions($type)
 
        $query .= ")";
 
-       $condition = array_merge([$query], $condition);
+       array_unshift($condition, $query);
 
        $params = ['order' => ['id' => true], 'limit' => [$start, $count]];
        $statuses = Post::selectForUser(api_user(), [], $condition, $params);
@@ -6007,7 +6007,7 @@ function bindComments(&$data)
        }
 
        $idStr = DBA::escape(implode(', ', $ids));
-       $sql = "SELECT `parent`, COUNT(*) as comments FROM `item` WHERE `parent` IN ($idStr) AND `deleted` = ? AND `gravity`= ? GROUP BY `parent`";
+       $sql = "SELECT `parent`, COUNT(*) as comments FROM `post-view` WHERE `parent` IN ($idStr) AND `deleted` = ? AND `gravity`= ? GROUP BY `parent`";
        $items = DBA::p($sql, 0, GRAVITY_COMMENT);
        $itemsData = DBA::toArray($items);