]> git.mxchange.org Git - friendica.git/commitdiff
API: several fixes to the Twitter/Statusnet API
authorMichael <heluecht@pirati.ca>
Fri, 25 Feb 2022 19:16:40 +0000 (19:16 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 25 Feb 2022 19:16:40 +0000 (19:16 +0000)
22 files changed:
src/Factory/Api/Twitter/Status.php
src/Module/Api/Friendica/Activity.php
src/Module/Api/Friendica/Events/Index.php
src/Module/Api/Friendica/Group/Show.php
src/Module/Api/Friendica/Photo.php
src/Module/Api/GNUSocial/Statusnet/Conversation.php
src/Module/Api/Twitter/Favorites.php
src/Module/Api/Twitter/Favorites/Create.php
src/Module/Api/Twitter/Favorites/Destroy.php
src/Module/Api/Twitter/Lists/Statuses.php
src/Module/Api/Twitter/Search/Tweets.php
src/Module/Api/Twitter/Statuses/Destroy.php
src/Module/Api/Twitter/Statuses/HomeTimeline.php
src/Module/Api/Twitter/Statuses/Mentions.php
src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php
src/Module/Api/Twitter/Statuses/PublicTimeline.php
src/Module/Api/Twitter/Statuses/Retweet.php
src/Module/Api/Twitter/Statuses/Show.php
src/Module/Api/Twitter/Statuses/UserTimeline.php
src/Module/Diaspora/Receive.php
src/Object/Api/Twitter/Status.php
static/routes.config.php

index 30cdb8bcf73ae47d6fe113808d5454ab7ad3bcdf..514b8f93a1f5d014dc76991b2dd35f9148ebac26 100644 (file)
@@ -70,7 +70,7 @@ class Status extends BaseFactory
         * @param int $uriId Uri-ID of the item
         * @param int $uid   Item user
         *
-        * @return \Friendica\Object\Api\Mastodon\Status
+        * @return \Friendica\Object\Api\Twitter\Status
         * @throws HTTPException\InternalServerErrorException
         * @throws ImagickException|HTTPException\NotFoundException
         */
@@ -89,13 +89,13 @@ class Status extends BaseFactory
         * @param int $uriId Uri-ID of the item
         * @param int $uid   Item user
         *
-        * @return \Friendica\Object\Api\Mastodon\Status
+        * @return \Friendica\Object\Api\Twitter\Status
         * @throws HTTPException\InternalServerErrorException
         * @throws ImagickException|HTTPException\NotFoundException
         */
        public function createFromUriId(int $uriId, $uid = 0, $include_entities = false): \Friendica\Object\Api\Twitter\Status
        {
-               $fields = ['id', 'parent', 'uri-id', 'uid', 'author-id', 'author-link', 'author-network', 'owner-id', 'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network',
+               $fields = ['parent-uri-id', 'uri-id', 'uid', 'author-id', 'author-link', 'author-network', 'owner-id', 'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network',
                        'thr-parent-id', 'parent-author-id', 'parent-author-nick', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'coord'];
                $item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
                if (!$item) {
@@ -108,7 +108,7 @@ class Status extends BaseFactory
         * @param array $item item array
         * @param int   $uid  Item user
         *
-        * @return \Friendica\Object\Api\Mastodon\Status
+        * @return \Friendica\Object\Api\Twitter\Status
         * @throws HTTPException\InternalServerErrorException
         * @throws ImagickException|HTTPException\NotFoundException
         */
index 3c892b3030e30628f1b100d27c0d75776e8524ca..204a508aab30b9fe65691771f6b3493e85383e08 100644 (file)
 
 namespace Friendica\Module\Api\Friendica;
 
-use Friendica\DI;
 use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Module\BaseApi;
+use Friendica\Network\HTTPException\BadRequestException;
 
 /**
  * API endpoints:
@@ -49,7 +50,12 @@ class Activity extends BaseApi
                        'id' => 0, // Id of the post
                ], $request);
 
-               $res = Item::performActivity($request['id'], $this->parameters['verb'], $uid);
+               $post = Post::selectFirst(['id'], ['uri-id' => $request['id'], 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
+               if (empty($post['id'])) {
+                       throw new BadRequestException('Item id not found');
+               }
+
+               $res = Item::performActivity($post['id'], $this->parameters['verb'], $uid);
 
                if ($res) {
                        if (($this->parameters['extension'] ?? '') == 'xml') {
index 594f85d4188ba6219c9d4e48bf224a335d0c5258..257c9f06f45c5eb8cd8f30a8ee4a00d770dd539e 100644 (file)
@@ -23,7 +23,6 @@ namespace Friendica\Module\Api\Friendica\Events;
 
 use Friendica\Content\Text\BBCode;
 use Friendica\Database\DBA;
-use Friendica\DI;
 use Friendica\Module\BaseApi;
 
 /**
@@ -40,7 +39,7 @@ class Index extends BaseApi
 
                $request = $this->getRequest([
                        'since_id' => 0,
-                       'count'    => 0,
+                       'count'    => 50,
                ], $request);
 
                $condition = ["`id` > ? AND `uid` = ?", $request['since_id'], $uid];
index d150827694b5a33b10c8607b1ded3c7e79f4ad0f..89c257e73d3b8d930d171551eebfd46a53bfcd8f 100644 (file)
@@ -32,7 +32,7 @@ use Friendica\Network\HTTPException;
  */
 class Show extends BaseApi
 {
-       protected function post(array $request = [])
+       protected function rawContent(array $request = [])
        {
                BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
                $uid  = BaseApi::getCurrentUserID();
index ba87081d4525c3b708627fdf73d559fc6b6d715e..b4b6a39970f78a9fb5dd1a65beca3aedf13cfc17 100644 (file)
@@ -44,7 +44,7 @@ class Photo extends BaseApi
                $this->friendicaPhoto = $friendicaPhoto;
        }
 
-       protected function post(array $request = [])
+       protected function rawContent(array $request = [])
        {
                BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
                $uid  = BaseApi::getCurrentUserID();
index 08cfe82fb928973b4fc95cb66a43d4ef7adb7850..65ef9654b860ef6c493b41e0a813b62a235919e9 100644 (file)
@@ -56,7 +56,7 @@ class Conversation extends BaseApi
                Logger::info(BaseApi::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' => $id]);
+               $item = Post::selectFirst(['parent-uri-id'], ['uri-id' => $id]);
                if (!DBA::isResult($item)) {
                        throw new BadRequestException("There is no status with the id $id.");
                }
@@ -68,15 +68,15 @@ class Conversation extends BaseApi
 
                $id = $parent['id'];
 
-               $condition = ["`parent` = ? AND `uid` IN (0, ?) AND `gravity` IN (?, ?) AND `id` > ?",
+               $condition = ["`parent` = ? AND `uid` IN (0, ?) AND `gravity` IN (?, ?) AND `uri-id` > ?",
                        $id, $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
 
                if ($max_id > 0) {
-                       $condition[0] .= " AND `id` <= ?";
+                       $condition[0] .= " AND `uri-id` <= ?";
                        $condition[] = $max_id;
                }
 
-               $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                $statuses = Post::selectForUser($uid, [], $condition, $params);
 
                if (!DBA::isResult($statuses)) {
index 828741a195a7193034879a5b00cceba38837041c..ea7ca42d5c3c926b6171ba2ed56e541cf17db840 100644 (file)
@@ -53,13 +53,13 @@ class Favorites extends BaseApi
 
                $start = max(0, ($page - 1) * $count);
 
-               $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ? AND `starred`",
+               $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `uri-id` > ? AND `starred`",
                        $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
 
-               $params = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
 
                if ($max_id > 0) {
-                       $condition[0] .= " AND `id` <= ?";
+                       $condition[0] .= " AND `uri-id` <= ?";
                        $condition[] = $max_id;
                }
 
index a9c6c962d521915d72513d00d089317d76f0cc57..6544fe470c7144d66c6549e963f4305c9c6908c9 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Twitter\Favorites;
 
 use Friendica\DI;
 use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Module\BaseApi;
 use Friendica\Network\HTTPException\BadRequestException;
 
@@ -42,9 +43,14 @@ class Create extends BaseApi
                        throw new BadRequestException('Item id not specified');
                }
 
-               Item::performActivity($id, 'like', $uid);
+               $post = Post::selectFirst(['id'], ['uri-id' => $request['id'], 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
+               if (empty($post['id'])) {
+                       throw new BadRequestException('Item id not found');
+               }
+
+               Item::performActivity($post['id'], 'like', $uid);
 
-               $status_info = DI::twitterStatus()->createFromItemId($id, $uid)->toArray();
+               $status_info = DI::twitterStatus()->createFromUriId($id, $uid)->toArray();
 
                $this->response->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
        }
index 0c25e9d188c8999b8a07113eb6c6ea905bc94760..0d3046afb136a671f96aafef91023dfdcca046fd 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Twitter\Favorites;
 
 use Friendica\DI;
 use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Module\BaseApi;
 use Friendica\Network\HTTPException\BadRequestException;
 
@@ -42,9 +43,14 @@ class Destroy extends BaseApi
                        throw new BadRequestException('Item id not specified');
                }
 
-               Item::performActivity($id, 'unlike', $uid);
+               $post = Post::selectFirst(['id'], ['uri-id' => $request['id'], 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
+               if (empty($post['id'])) {
+                       throw new BadRequestException('Item id not found');
+               }
+
+               Item::performActivity($post['id'], 'unlike', $uid);
 
-               $status_info = DI::twitterStatus()->createFromItemId($id, $uid)->toArray();
+               $status_info = DI::twitterStatus()->createFromUriId($id, $uid)->toArray();
 
                $this->response->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null);
        }
index 2bf27697b4fd981106b0053c42c0613c19b446d1..177c5fd0babe3aef99201ebe5ab6c93eb1ecd6d6 100644 (file)
@@ -78,10 +78,10 @@ class Statuses extends BaseApi
                $groups    = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
                $gids      = array_column($groups, 'contact-id');
                $condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
-               $condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
+               $condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
 
                if ($max_id > 0) {
-                       $condition[0] .= " AND `id` <= ?";
+                       $condition[0] .= " AND `uri-id` <= ?";
                        $condition[] = $max_id;
                }
                if ($exclude_replies) {
@@ -89,11 +89,11 @@ class Statuses extends BaseApi
                        $condition[] = GRAVITY_PARENT;
                }
                if ($conversation_id > 0) {
-                       $condition[0] .= " AND `parent` = ?";
+                       $condition[0] .= " AND `parent-uri-id` = ?";
                        $condition[] = $conversation_id;
                }
 
-               $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                $statuses = Post::selectForUser($uid, [], $condition, $params);
 
                $items = [];
index 5da579b7cec6effd43ec240cb8b2f720d707ee6c..db25c4eb96928a563d129f259808a18c95909263 100644 (file)
@@ -59,10 +59,10 @@ class Tweets extends BaseApi
 
                $start = max(0, ($page - 1) * $count);
 
-               $params = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                if (preg_match('/^#(\w+)$/', $searchTerm, $matches) === 1 && isset($matches[1])) {
                        $searchTerm = $matches[1];
-                       $condition  = ["`iid` > ? AND `name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))", $since_id, $searchTerm, $uid];
+                       $condition  = ["`uri-id` > ? AND `name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))", $since_id, $searchTerm, $uid];
 
                        $tags   = DBA::select('tag-search-view', ['uri-id'], $condition);
                        $uriids = [];
@@ -83,13 +83,13 @@ class Tweets extends BaseApi
 
                        $params['group_by'] = ['uri-id'];
                } else {
-                       $condition = ["`id` > ?
+                       $condition = ["`uri-id` > ?
                                " . ($exclude_replies ? " AND `gravity` = " . GRAVITY_PARENT : ' ') . "
                                AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))
                                AND `body` LIKE CONCAT('%',?,'%')",
                                $since_id, $uid, $_REQUEST['q']];
                        if ($max_id > 0) {
-                               $condition[0] .= ' AND `id` <= ?';
+                               $condition[0] .= ' AND `uri-id` <= ?';
                                $condition[] = $max_id;
                        }
                }
index be08483532887534edd1d8409075edd126f8e641..e54166b990b3182a7faf501990e5d06422a4ea2a 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\Module\BaseApi;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Network\HTTPException\BadRequestException;
 
 /**
@@ -45,13 +46,18 @@ class Destroy extends BaseApi
                        throw new BadRequestException('An id is missing.');
                }
 
+               $post = Post::selectFirst(['id'], ['uri-id' => $request['id'], 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
+               if (empty($post['id'])) {
+                       throw new BadRequestException('Item id not found');
+               }
+
                $this->logger->notice('API: api_statuses_destroy: ' . $id);
 
                $include_entities = $this->getRequestValue($request, 'include_entities', false);
 
-               $ret = DI::twitterStatus()->createFromItemId($id, $uid, $include_entities)->toArray();
+               $ret = DI::twitterStatus()->createFromUriId($id, $uid, $include_entities)->toArray();
 
-               Item::deleteForUser(['id' => $id], $uid);
+               Item::deleteForUser(['id' => $post['id']], $uid);
 
                $this->response->exit('status', ['status' => $ret], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
        }
index 41314bb1b7ab614f62b67ba9532fdb7edc3425b6..a607d4c950a2c6eda044ee6ad193f77e39df676d 100644 (file)
@@ -53,11 +53,11 @@ class HomeTimeline extends BaseApi
 
                $start = max(0, ($page - 1) * $count);
 
-               $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ?",
+               $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `uri-id` > ?",
                        $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
 
                if ($max_id > 0) {
-                       $condition[0] .= " AND `id` <= ?";
+                       $condition[0] .= " AND `uri-id` <= ?";
                        $condition[] = $max_id;
                }
                if ($exclude_replies) {
@@ -65,11 +65,11 @@ class HomeTimeline extends BaseApi
                        $condition[] = GRAVITY_PARENT;
                }
                if ($conversation_id > 0) {
-                       $condition[0] .= " AND `parent` = ?";
+                       $condition[0] .= " AND `parent-uri-id` = ?";
                        $condition[] = $conversation_id;
                }
 
-               $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                $statuses = Post::selectForUser($uid, [], $condition, $params);
 
                $ret     = [];
index e9bbb93bdf413f00acc12e4bb0591f5780af053e..800a91110be264b7ebd8aba1f78cf5fa58d6814e 100644 (file)
@@ -52,7 +52,7 @@ class Mentions extends BaseApi
 
                $query = "`gravity` IN (?, ?) AND `uri-id` IN
                        (SELECT `uri-id` FROM `post-user-notification` WHERE `uid` = ? AND `notification-type` & ? != 0 ORDER BY `uri-id`)
-                       AND (`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `id` > ?";
+                       AND (`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `uri-id` > ?";
 
                $condition = [
                        GRAVITY_PARENT, GRAVITY_COMMENT,
@@ -64,13 +64,13 @@ class Mentions extends BaseApi
                ];
 
                if ($max_id > 0) {
-                       $query .= " AND `id` <= ?";
+                       $query .= " AND `uri-id` <= ?";
                        $condition[] = $max_id;
                }
 
                array_unshift($condition, $query);
 
-               $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                $statuses = Post::selectForUser($uid, [], $condition, $params);
 
                $ret = [];
index af0436b4a29afa6ae502ccd88ae1edb65c8f327e..96469fb4370682bce5aa110f2128245178053b54 100644 (file)
@@ -46,15 +46,15 @@ class NetworkPublicTimeline extends BaseApi
 
                $start = max(0, ($page - 1) * $count);
 
-               $condition = ["`uid` = 0 AND `gravity` IN (?, ?) AND `id` > ? AND `private` = ?",
+               $condition = ["`uid` = 0 AND `gravity` IN (?, ?) AND `uri-id` > ? AND `private` = ?",
                        GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, Item::PUBLIC];
 
                if ($max_id > 0) {
-                       $condition[0] .= " AND `id` <= ?";
+                       $condition[0] .= " AND `uri-id` <= ?";
                        $condition[] = $max_id;
                }
 
-               $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                $statuses = Post::selectForUser($uid, Item::DISPLAY_FIELDLIST, $condition, $params);
 
                $ret = [];
index aba330a658bbc047a2d7991cdd46ffcc1af81e9d..a247e6688f93fee0dc1834b86ccc5ee33b29323a 100644 (file)
@@ -52,30 +52,30 @@ class PublicTimeline extends BaseApi
                $start = max(0, ($page - 1) * $count);
 
                if ($exclude_replies && !$conversation_id) {
-                       $condition = ["`gravity` = ? AND `id` > ? AND `private` = ? AND `wall` AND NOT `author-hidden`",
+                       $condition = ["`gravity` = ? AND `uri-id` > ? AND `private` = ? AND `wall` AND NOT `author-hidden`",
                                GRAVITY_PARENT, $since_id, Item::PUBLIC];
 
                        if ($max_id > 0) {
-                               $condition[0] .= " AND `id` <= ?";
+                               $condition[0] .= " AND `uri-id` <= ?";
                                $condition[] = $max_id;
                        }
 
-                       $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+                       $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                        $statuses = Post::selectForUser($uid, [], $condition, $params);
                } else {
-                       $condition = ["`gravity` IN (?, ?) AND `id` > ? AND `private` = ? AND `wall` AND `origin` AND NOT `author-hidden`",
+                       $condition = ["`gravity` IN (?, ?) AND `uri-id` > ? AND `private` = ? AND `wall` AND `origin` AND NOT `author-hidden`",
                                GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, Item::PUBLIC];
 
                        if ($max_id > 0) {
-                               $condition[0] .= " AND `id` <= ?";
+                               $condition[0] .= " AND `uri-id` <= ?";
                                $condition[] = $max_id;
                        }
                        if ($conversation_id > 0) {
-                               $condition[0] .= " AND `parent` = ?";
+                               $condition[0] .= " AND `parent-uri-id` = ?";
                                $condition[] = $conversation_id;
                        }
 
-                       $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+                       $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                        $statuses = Post::selectForUser($uid, [], $condition, $params);
                }
 
index 1d67443b1c27d0d5b0c06c836b0260071f3ed1ba..d89c2300b8ff02118f7ca85c6e1f00ee6435abc8 100644 (file)
@@ -50,8 +50,8 @@ class Retweet extends BaseApi
                        throw new BadRequestException('An id is missing.');
                }
 
-               $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
-               $item   = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
+               $fields = ['id', 'uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
+               $item   = Post::selectFirst($fields, ['uri-id' => $id, 'uid' => [0, $uid], 'private' => [Item::PUBLIC, Item::UNLISTED]], ['order' => ['uid' => true]]);
 
                if (DBA::isResult($item) && !empty($item['body'])) {
                        if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) {
@@ -59,7 +59,7 @@ class Retweet extends BaseApi
                                        throw new InternalServerErrorException();
                                }
 
-                               $item_id = $id;
+                               $item_id = $item['id'];
                        } else {
                                $item_id = Diaspora::performReshare($item['uri-id'], $uid);
                        }
index 64533d0bc9c89c52dda91e990f8bbdbe04ca363b..16bf4626780d69ed53c5f7eb1c481cdec299f3ef 100644 (file)
@@ -52,23 +52,18 @@ class Show extends BaseApi
                $conversation = !empty($request['conversation']);
 
                // try to fetch the item for the local user - or the public item, if there is no local one
-               $uri_item = Post::selectFirst(['uri-id'], ['id' => $id]);
-               if (!DBA::isResult($uri_item)) {
-                       throw new BadRequestException(sprintf("There is no status with the id %d", $id));
-               }
-
-               $item = Post::selectFirst(['id'], ['uri-id' => $uri_item['uri-id'], 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
+               $item = Post::selectFirst(['id'], ['uri-id' => $id, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
                if (!DBA::isResult($item)) {
-                       throw new BadRequestException(sprintf("There is no status with the uri-id %d for the given user.", $uri_item['uri-id']));
+                       throw new BadRequestException(sprintf("There is no status with the uri-id %d for the given user.", $id));
                }
 
-               $id = $item['id'];
+               $item_id = $item['id'];
 
                if ($conversation) {
-                       $condition = ['parent' => $id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
-                       $params    = ['order' => ['id' => true]];
+                       $condition = ['parent' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
+                       $params    = ['order' => ['uri-id' => true]];
                } else {
-                       $condition = ['id' => $id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
+                       $condition = ['id' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
                        $params    = [];
                }
 
index b6dcd86c9199041d3fb741ccd20f82056b3d401d..05aa079624923e97cdb64dc3ffd00571cbf64296 100644 (file)
@@ -53,7 +53,7 @@ class UserTimeline extends BaseApi
 
                $start = max(0, ($page - 1) * $count);
 
-               $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`)) AND `gravity` IN (?, ?) AND `id` > ? AND `author-id` = ?",
+               $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`)) AND `gravity` IN (?, ?) AND `uri-id` > ? AND `author-id` = ?",
                        0, $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $cid];
 
                if ($exclude_replies) {
@@ -62,15 +62,15 @@ class UserTimeline extends BaseApi
                }
 
                if ($conversation_id > 0) {
-                       $condition[0] .= " AND `parent` = ?";
+                       $condition[0] .= " AND `parent-uri-id` = ?";
                        $condition[] = $conversation_id;
                }
 
                if ($max_id > 0) {
-                       $condition[0] .= " AND `id` <= ?";
+                       $condition[0] .= " AND `uri-id` <= ?";
                        $condition[] = $max_id;
                }
-               $params   = ['order' => ['id' => true], 'limit' => [$start, $count]];
+               $params   = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
                $statuses = Post::selectForUser($uid, [], $condition, $params);
 
                $ret = [];
index 19de0873ffe91a881f486cb88f449ac573c0943b..fd8c201d4ded591d6adcf0897f6eba0121d28658 100644 (file)
@@ -92,6 +92,11 @@ class Receive extends BaseModule
                $this->logger->info('Diaspora: Receiving post.');
 
                $importer = User::getByGuid($this->parameters['guid']);
+               if (empty($importer)) {
+                       // We haven't found the user.
+                       // To avoid the remote system trying again we send the message that we accepted the content.
+                       throw new HTTPException\AcceptedException();
+               }
 
                if ($importer['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
                        // Communities aren't working with the Diaspora protoccol
@@ -99,7 +104,7 @@ class Receive extends BaseModule
                        throw new HTTPException\AcceptedException();
                }
 
-               $msg = $this->decodePost(false, $importer['prvkey'] ?? '');
+               $msg = $this->decodePost(false, $importer['prvkey']);
 
                $this->logger->info('Diaspora: Dispatching.');
 
index 9c1d5d37460317bd8c5f47672480a8093f9cbd57..7640cc3e9219c796bedb931c8f2de2c0360c13b6 100644 (file)
@@ -100,9 +100,9 @@ class Status extends BaseDataTransferObject
         */
        public function __construct(string $text, string $statusnetHtml, string $friendicaHtml, array $item, User $author, User $owner, array $retweeted, array $quoted, array $geo, array $friendica_activities, array $entities, array $attachments, int $friendica_comments, bool $liked)
        {
-               $this->id                        = (int)$item['id'];
-               $this->id_str                    = (string)$item['id'];
-               $this->statusnet_conversation_id = (int)$item['parent'];
+               $this->id                        = (int)$item['uri-id'];
+               $this->id_str                    = (string)$item['uri-id'];
+               $this->statusnet_conversation_id = (int)$item['parent-uri-id'];
 
                $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::API);
 
index 758462ca034911afa578d667d082471fc415819d..e10ec2aedff3684c3f0de795960a1c64a7171c15 100644 (file)
@@ -77,6 +77,7 @@ $apiRoutes = [
                        => [Module\Api\Friendica\Activity::class, [        R::POST]],
                '/notification/seen[.{extension:json|xml|rss|atom}]'       => [Module\Api\Friendica\Notification\Seen::class,      [        R::POST]],
                '/notification[.{extension:json|xml|rss|atom}]'            => [Module\Api\Friendica\Notification::class,           [R::GET         ]],
+               '/notifications[.{extension:json|xml|rss|atom}]'           => [Module\Api\Friendica\Notification::class,           [R::GET         ]],
                '/direct_messages_setseen[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\DirectMessages\Setseen::class, [        R::POST]],
                '/direct_messages_search[.{extension:json|xml|rss|atom}]'  => [Module\Api\Friendica\DirectMessages\Search ::class, [R::GET         ]],
                '/events[.{extension:json|xml|rss|atom}]'                  => [Module\Api\Friendica\Events\Index::class,           [R::GET         ]],