From d78892fc1bbbece820ab2ac5be766b59dde7a54d Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Sun, 17 Jan 2021 14:57:55 +0000
Subject: [PATCH] Improved API datasets

---
 include/api.php                |  4 ++--
 tests/datasets/api.fixture.php | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/api.php b/include/api.php
index 63df897ee0..ccb6f718ea 100644
--- a/include/api.php
+++ b/include/api.php
@@ -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.");
 	}
diff --git a/tests/datasets/api.fixture.php b/tests/datasets/api.fixture.php
index ca3fc3d1d1..f8c696c877 100644
--- a/tests/datasets/api.fixture.php
+++ b/tests/datasets/api.fixture.php
@@ -194,6 +194,8 @@ return [
 			'body'        => 'Parent status',
 			'parent'      => 1,
 			'parent-uri-id' => 1,
+			'thr-parent-id' => 1,
+			'gravity'     => GRAVITY_PARENT,
 			'author-link' => 'http://localhost/profile/selfcontact',
 			'wall'        => 1,
 			'starred'     => 1,
@@ -219,6 +221,8 @@ return [
 			'body'        => 'Reply',
 			'parent'      => 1,
 			'parent-uri-id' => 1,
+			'thr-parent-id' => 1,
+			'gravity'     => GRAVITY_COMMENT,
 			'author-link' => 'http://localhost/profile/selfcontact',
 			'wall'        => 1,
 			'starred'     => 0,
@@ -241,6 +245,8 @@ return [
 			'body'        => 'Other user status',
 			'parent'      => 3,
 			'parent-uri-id' => 3,
+			'thr-parent-id' => 3,
+			'gravity'     => GRAVITY_PARENT,
 			'author-link' => 'http://localhost/profile/othercontact',
 			'wall'        => 1,
 			'starred'     => 0,
@@ -262,6 +268,8 @@ return [
 			'body'        => 'Friend user reply',
 			'parent'      => 1,
 			'parent-uri-id' => 1,
+			'thr-parent-id' => 1,
+			'gravity'     => GRAVITY_COMMENT,
 			'author-link' => 'http://localhost/profile/othercontact',
 			'wall'        => 1,
 			'starred'     => 0,
@@ -284,6 +292,8 @@ return [
 			'body'        => '[share]Shared status[/share]',
 			'parent'      => 1,
 			'parent-uri-id' => 1,
+			'thr-parent-id' => 1,
+			'gravity'     => GRAVITY_COMMENT,
 			'author-link' => 'http://localhost/profile/othercontact',
 			'wall'        => 1,
 			'starred'     => 0,
@@ -309,6 +319,8 @@ return [
 			'body'        => 'Friend user status',
 			'parent'      => 6,
 			'parent-uri-id' => 6,
+			'thr-parent-id' => 6,
+			'gravity'     => GRAVITY_PARENT,
 			'author-link' => 'http://localhost/profile/othercontact',
 			'wall'        => 1,
 			'starred'     => 0,