From 1dd48791978f195ddcc5934c994fd035a8a45143 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Wed, 6 May 2020 15:19:06 +0000
Subject: [PATCH] Item view is working

---
 static/dbview.config.php | 164 ++++++++++++++++++++-------------------
 1 file changed, 85 insertions(+), 79 deletions(-)

diff --git a/static/dbview.config.php b/static/dbview.config.php
index 6c75ac037..cb41d0637 100755
--- a/static/dbview.config.php
+++ b/static/dbview.config.php
@@ -39,83 +39,87 @@
 return [
 	"item-view" => [
 		"fields" => [
-/*
-"uid" => ["item", ""], 
-"parent" => ["item", ""], 
-"uri" => ["item", ""], 
-"parent-uri" => ["item", ""], 
-"thr-parent" => ["item", ""],
-"guid" => ["item", ""], 
-"uri-id" => ["item", ""], 
-"parent-uri-id" => ["item", ""], 
-"thr-parent-id" => ["item", ""],
-"contact-id" => ["item", ""], 
-"type" => ["item", ""], 
-"wall" => ["item", ""], 
-"gravity" => ["item", ""], 
-"extid" => ["item", ""], 
-"psid" => ["item", ""], 
-"created" => ["item", ""], 
-"edited" => ["item", ""], 
-"commented" => ["item", ""], 
-"received" => ["item", ""], 
-"changed" => ["item", ""], 
-"verb" => ["", ""], 
-"postopts" => ["", ""], 
-"plink" => ["", ""], 
-"resource-id" => ["item", ""], 
-"event-id" => ["item", ""], 
-"attach" => ["item", ""], 
-"inform" => ["", ""], 
-"file" => ["", ""], 
-"allow_cid" => ["", ""], 
-"allow_gid" => ["", ""], 
-"deny_cid" => ["", ""], 
-"deny_gid" => ["", ""], 
-"post-type" => ["item", ""], 
-"private" => ["item", ""], 
-"pubmail" => ["item", ""], 
-"moderated" => ["item", ""], 
-"visible" => ["item", ""], 
-"starred" => ["item", ""], 
-"bookmark" => ["", ""], 
-"unseen" => ["item", ""], 
-"deleted" => ["item", ""], 
-"origin" => ["item", ""], 
-"forum_mode" => ["item", ""], 
-"mention" => ["item", ""], 
-"global" => ["item", ""], 
-"network" => ["item", ""], 
-"title" => ["", ""], 
-"content-warning" => ["", ""], 
-"body" => ["", ""], 
-"location" => ["", ""], 
-"coord" => ["", ""], 
-"app" => ["", ""], 
-"rendered-hash" => ["", ""], 
-"rendered-html" => ["", ""], 
-"object-type" => ["", ""], 
-"object" => ["", ""], 
-"target-type" => ["", ""], 
-"target" => ["", ""], 
-"author-id" => ["item", ""], 
-"author-link" => ["author", ""], 
-"author-name" => ["author", ""], 
-"author-avatar" => ["author", ""], 
-"author-network" => ["author", ""], 
-"owner-id" => ["item", ""], 
-"owner-link" => ["owner", ""], 
-"owner-name" => ["owner", ""], 
-"owner-avatar"  => ["owner", ""]
-*/
-			"uri-id" => ["post-category", "uri-id"],
-			"uid" => ["post-category", "uid"],
-			"uri" => ["item-uri", "uri"],
-			"guid" => ["item-uri", "guid"],
-			"type" => ["post-category", "type"],
-			"tid" => ["post-category", "tid"],
-			"name" => ["tag", "name"],
-			"url" => ["tag", "url"],
+			"id" => ["item", "id"], 
+			"item_id" => ["item", "id"], 
+			"uid" => ["item", "uid"], 
+			"parent" => ["item", "parent"], 
+			"uri" => ["item", "uri"], 
+			"parent-uri" => ["item", "parent-uri"], 
+			"thr-parent" => ["item", "thr-parent"],
+			"guid" => ["item", "guid"], 
+			"uri-id" => ["item", "uri-id"], 
+			"parent-uri-id" => ["item", "parent-uri-id"], 
+			"thr-parent-id" => ["item", "thr-parent-id"],
+			"contact-id" => ["item", "contact-id"], 
+			"type" => ["item", "type"], 
+			"wall" => ["item", "wall"], 
+			"gravity" => ["item", "gravity"], 
+			"extid" => ["item", "extid"], 
+			"iaid" => ["item", "iaid"],
+			"icid" => ["item", "icid"],
+			"psid" => ["item", "psid"],
+			"created" => ["item", "created"], 
+			"edited" => ["item", "edited"], 
+			"commented" => ["item", "commented"], 
+			"received" => ["item", "received"], 
+			"changed" => ["item", "changed"], 
+			"verb" => ["item-content", "verb"], 
+			"plink" => ["item-content", "plink"], 
+			"language" => ["item-content", "language"],
+			"resource-id" => ["item", "resource-id"], 
+			"event-id" => ["item", "event-id"], 
+			"attach" => ["item", "attach"], 
+			"postopts" => ["post-delivery-data", "postopts"], 
+			"inform" => ["post-delivery-data", "inform"], 
+			"file" => "NULL", 
+			"allow_cid" => ["permissionset", "allow_cid"], 
+			"allow_gid" => ["permissionset", "allow_gid"], 
+			"deny_cid" => ["permissionset", "deny_cid"], 
+			"deny_gid" => ["permissionset", "deny_gid"], 
+			"post-type" => ["item", "post-type"], 
+			"private" => ["item", "private"], 
+			"pubmail" => ["item", "pubmail"], 
+			"moderated" => ["item", "moderated"], 
+			"visible" => ["item", "visible"], 
+			"starred" => ["item", "starred"], 
+			"bookmark" => ["thread", "bookmark"], 
+			"unseen" => ["item", "unseen"], 
+			"deleted" => ["item", "deleted"], 
+			"origin" => ["item", "origin"], 
+			"forum_mode" => ["item", "forum_mode"], 
+			"mention" => ["item", "mention"], 
+			"global" => ["item", "global"], 
+			"network" => ["item", "network"], 
+			"title" => ["item-content", "title"], 
+			"content-warning" => ["item-content", "content-warning"], 
+			"body" => ["item-content", "body"], 
+			"location" => ["item-content", "location"], 
+			"coord" => ["item-content", "coord"], 
+			"app" => ["item-content", "app"], 
+			"rendered-hash" => ["item-content", "rendered-hash"], 
+			"rendered-html" => ["item-content", "rendered-html"], 
+			"object-type" => ["item-content", "object-type"], 
+			"object" => ["item-content", "object"], 
+			"target-type" => ["item-content", "target-type"], 
+			"target" => ["item-content", "target"], 
+			"author-id" => ["item", "author-id"], 
+			"author-link" => ["author", "url"], 
+			"author-name" => ["author", "name"], 
+			"author-avatar" => ["author", "thumb"], 
+			"author-network" => ["author", "network"], 
+			"owner-id" => ["item", "owner-id"], 
+			"owner-link" => ["owner", "url"], 
+			"owner-addr" => ["owner", "addr"], 
+			"owner-avatar"  => ["owner", "thumb"],
+			"owner-nick" => ["owner", "nick"], 
+			"owner-name" => ["owner", "name"], 
+			"owner-network" => ["owner", "network"],
+			"contact-uid" => ["contact", "uid"],
+			"parent-guid" => ["parent-item", "guid"],
+			"parent-network" => ["parent-item", "network"],
+			"signed_text" => ["diaspora-interaction", "interaction"],
+			"signature" => "NULL",
+			"signer" => "NULL"
 		],
 		"query" => "FROM `item`
 			LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@@ -124,8 +128,10 @@ return [
 			LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
 			LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id`
 			LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
-			LEFT JOIN `item-delivery-data` ON `item-delivery-data`.`iid` = `item`.`id`
-			LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`"
+			LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
+			LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
+			LEFT JOIN `thread` ON `thread`.`iid` = `item`.`parent`
+			STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`"
 	],
 	"category-view" => [
 		"fields" => [