]> git.mxchange.org Git - friendica.git/blob - static/dbview.config.php
Merge pull request #11888 from MrPetovan/bug/11861-frio-filerm
[friendica.git] / static / dbview.config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  * Main view structure configuration file.
21  *
22  * Here are described all the view Friendica needs to work.
23  *
24  * Syntax (braces indicate optionale values):
25  * "<view name>" => [
26  *      "fields" => [
27  *              "<field name>" => ["table", "field"],
28  *              "<field name>" => "SQL expression",
29  *              ...
30  *      ],
31  *      "query" => "FROM `table` INNER JOIN `other-table` ..."
32  *      ],
33  * ],
34  *
35  * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value in dbstructure.config.php.
36  *
37  */
38
39  return [
40         "application-view" => [
41                 "fields" => [
42                         "id" => ["application", "id"],
43                         "uid" => ["application-token", "uid"],
44                         "name" => ["application", "name"],
45                         "redirect_uri" => ["application", "redirect_uri"],
46                         "website" => ["application", "website"],
47                         "client_id" => ["application", "client_id"],
48                         "client_secret" => ["application", "client_secret"],
49                         "code" => ["application-token", "code"],
50                         "access_token" => ["application-token", "access_token"],
51                         "created_at" => ["application-token", "created_at"],
52                         "scopes" => ["application-token", "scopes"],
53                         "read" => ["application-token", "read"],
54                         "write" => ["application-token", "write"],
55                         "follow" => ["application-token", "follow"],
56                         "push" => ["application-token", "push"],
57                 ],
58                 "query" => "FROM `application-token`
59                         INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`"
60         ],
61         "post-user-view" => [
62                 "fields" => [
63                         "id" => ["post-user", "id"],
64                         "post-user-id" => ["post-user", "id"],
65                         "uid" => ["post-user", "uid"],
66                         "parent" => ["parent-post", "id"],
67                         "uri" => ["item-uri", "uri"],
68                         "uri-id" => ["post-user", "uri-id"],
69                         "parent-uri" => ["parent-item-uri", "uri"],
70                         "parent-uri-id" => ["post-user", "parent-uri-id"],
71                         "thr-parent" => ["thr-parent-item-uri", "uri"],
72                         "thr-parent-id" => ["post-user", "thr-parent-id"],
73                         "conversation" => ["conversation-item-uri", "uri"],
74                         "conversation-id" => ["post-thread-user", "conversation-id"],
75                         "guid" => ["item-uri", "guid"],
76                         "wall" => ["post-user", "wall"],
77                         "gravity" => ["post-user", "gravity"],
78                         "extid" => ["external-item-uri", "uri"],
79                         "external-id" => ["post-user", "external-id"],
80                         "created" => ["post-user", "created"],
81                         "edited" => ["post-user", "edited"],
82                         "commented" => ["post-thread-user", "commented"],
83                         "received" => ["post-user", "received"],
84                         "changed" => ["post-thread-user", "changed"],
85                         "post-type" => ["post-user", "post-type"],
86                         "post-reason" => ["post-user", "post-reason"],
87                         "private" => ["post-user", "private"],
88                         "pubmail" => ["post-thread-user", "pubmail"],
89                         "visible" => ["post-user", "visible"],
90                         "starred" => ["post-thread-user", "starred"],
91                         "unseen" => ["post-user", "unseen"],
92                         "deleted" => ["post-user", "deleted"],
93                         "origin" => ["post-user", "origin"],
94                         "parent-origin" => ["post-thread-user", "origin"],
95                         "mention" => ["post-thread-user", "mention"],
96                         "global" => ["post-user", "global"],
97                         "featured" => "EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`)",
98                         "network" => ["post-user", "network"],
99                         "protocol" => ["post-user", "protocol"],
100                         "vid" => ["post-user", "vid"],
101                         "psid" => ["post-user", "psid"],
102                         "verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
103                         "title" => ["post-content", "title"],
104                         "content-warning" => ["post-content", "content-warning"],
105                         "raw-body" => ["post-content", "raw-body"],
106                         "body" => "IFNULL (`post-content`.`body`, '')",
107                         "rendered-hash" => ["post-content", "rendered-hash"],
108                         "rendered-html" => ["post-content", "rendered-html"],
109                         "language" => ["post-content", "language"],
110                         "plink" => ["post-content", "plink"],
111                         "location" => ["post-content", "location"],
112                         "coord" => ["post-content", "coord"],
113                         "app" => ["post-content", "app"],
114                         "object-type" => ["post-content", "object-type"],
115                         "object" => ["post-content", "object"],
116                         "target-type" => ["post-content", "target-type"],
117                         "target" => ["post-content", "target"],
118                         "resource-id" => ["post-content", "resource-id"],
119                         "contact-id" => ["post-user", "contact-id"],
120                         "contact-uri-id" => ["contact", "uri-id"],
121                         "contact-link" => ["contact", "url"],
122                         "contact-addr" => ["contact", "addr"],
123                         "contact-name" => ["contact", "name"],
124                         "contact-nick" => ["contact", "nick"],
125                         "contact-avatar" => ["contact", "thumb"],
126                         "contact-network" => ["contact", "network"],
127                         "contact-blocked" => ["contact", "blocked"],
128                         "contact-hidden" => ["contact", "hidden"],
129                         "contact-readonly" => ["contact", "readonly"],
130                         "contact-archive" => ["contact", "archive"],
131                         "contact-pending" => ["contact", "pending"],
132                         "contact-rel" => ["contact", "rel"],
133                         "contact-uid" => ["contact", "uid"],
134                         "contact-contact-type" => ["contact", "contact-type"],
135                         "writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
136                         "self" => ["contact", "self"],
137                         "cid" => ["contact", "id"],
138                         "alias" => ["contact", "alias"],
139                         "photo" => ["contact", "photo"],
140                         "name-date" => ["contact", "name-date"],
141                         "uri-date" => ["contact", "uri-date"],
142                         "avatar-date" => ["contact", "avatar-date"],
143                         "thumb" => ["contact", "thumb"],
144                         "author-id" => ["post-user", "author-id"],
145                         "author-uri-id" => ["author", "uri-id"],
146                         "author-link" => ["author", "url"],
147                         "author-addr" => ["author", "addr"],
148                         "author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
149                         "author-nick" => ["author", "nick"],
150                         "author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
151                         "author-network" => ["author", "network"],
152                         "author-blocked" => ["author", "blocked"],
153                         "author-hidden" => ["author", "hidden"],
154                         "author-updated" => ["author", "updated"],
155                         "author-gsid" => ["author", "gsid"],
156                         "author-uri-id" => ["author", "uri-id"],
157                         "owner-id" => ["post-user", "owner-id"],
158                         "owner-uri-id" => ["owner", "uri-id"],
159                         "owner-link" => ["owner", "url"],
160                         "owner-addr" => ["owner", "addr"],
161                         "owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
162                         "owner-nick" => ["owner", "nick"],
163                         "owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
164                         "owner-network" => ["owner", "network"],
165                         "owner-blocked" => ["owner", "blocked"],
166                         "owner-hidden" => ["owner", "hidden"],
167                         "owner-updated" => ["owner", "updated"],
168                         "owner-contact-type" => ["owner", "contact-type"],
169                         "causer-id" => ["post-user", "causer-id"],
170                         "causer-uri-id" => ["causer", "uri-id"],
171                         "causer-link" => ["causer", "url"],
172                         "causer-addr" => ["causer", "addr"],
173                         "causer-name" => ["causer", "name"],
174                         "causer-nick" => ["causer", "nick"],
175                         "causer-avatar" => ["causer", "thumb"],
176                         "causer-network" => ["causer", "network"],
177                         "causer-blocked" => ["causer", "blocked"],
178                         "causer-hidden" => ["causer", "hidden"],
179                         "causer-contact-type" => ["causer", "contact-type"],
180                         "postopts" => ["post-delivery-data", "postopts"],
181                         "inform" => ["post-delivery-data", "inform"],
182                         "delivery_queue_count" => ["post-delivery-data", "queue_count"],
183                         "delivery_queue_done" => ["post-delivery-data", "queue_done"],
184                         "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
185                         "allow_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
186                         "allow_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
187                         "deny_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
188                         "deny_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
189                         "event-id" => ["post-user", "event-id"],
190                         "event-created" => ["event", "created"],
191                         "event-edited" => ["event", "edited"],
192                         "event-start" => ["event", "start"],
193                         "event-finish" => ["event", "finish"],
194                         "event-summary" => ["event", "summary"],
195                         "event-desc" => ["event", "desc"],
196                         "event-location" => ["event", "location"],
197                         "event-type" => ["event", "type"],
198                         "event-nofinish" => ["event", "nofinish"],
199                         "event-ignore" => ["event", "ignore"],
200                         "question-id" => ["post-question", "id"],
201                         "question-multiple" => ["post-question", "multiple"],
202                         "question-voters" => ["post-question", "voters"],
203                         "question-end-time" => ["post-question", "end-time"],
204                         "has-categories" => "EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-user`.`uri-id` AND `post-category`.`uid` = `post-user`.`uid`)",
205                         "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`)",
206                         "signed_text" => ["diaspora-interaction", "interaction"],
207                         "parent-guid" => ["parent-item-uri", "guid"],
208                         "parent-network" => ["parent-post", "network"],
209                         "parent-author-id" => ["parent-post", "author-id"],
210                         "parent-author-link" => ["parent-post-author", "url"],
211                         "parent-author-name" => ["parent-post-author", "name"],
212                         "parent-author-nick" => ["parent-post-author", "nick"],
213                         "parent-author-network" => ["parent-post-author", "network"],
214                         "parent-author-blocked" => ["parent-post-author", "blocked"],
215                         "parent-author-hidden" => ["parent-post-author", "hidden"],
216                 ],
217                 "query" => "FROM `post-user`
218                         STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
219                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
220                         STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
221                         STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
222                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
223                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
224                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
225                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
226                         LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
227                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
228                         LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
229                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
230                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
231                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
232                         LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
233                         LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
234                         LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
235                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
236                         LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
237         ],
238         "post-thread-user-view" => [
239                 "fields" => [
240                         "id" => ["post-user", "id"],
241                         "post-user-id" => ["post-user", "id"],
242                         "uid" => ["post-thread-user", "uid"],
243                         "parent" => ["parent-post", "id"],
244                         "uri" => ["item-uri", "uri"],
245                         "uri-id" => ["post-thread-user", "uri-id"],
246                         "parent-uri" => ["parent-item-uri", "uri"],
247                         "parent-uri-id" => ["post-user", "parent-uri-id"],
248                         "thr-parent" => ["thr-parent-item-uri", "uri"],
249                         "thr-parent-id" => ["post-user", "thr-parent-id"],
250                         "conversation" => ["conversation-item-uri", "uri"],
251                         "conversation-id" => ["post-thread-user", "conversation-id"],
252                         "guid" => ["item-uri", "guid"],
253                         "wall" => ["post-thread-user", "wall"],
254                         "gravity" => ["post-user", "gravity"],
255                         "extid" => ["external-item-uri", "uri"],
256                         "external-id" => ["post-user", "external-id"],
257                         "created" => ["post-thread-user", "created"],
258                         "edited" => ["post-user", "edited"],
259                         "commented" => ["post-thread-user", "commented"],
260                         "received" => ["post-thread-user", "received"],
261                         "changed" => ["post-thread-user", "changed"],
262                         "post-type" => ["post-user", "post-type"],
263                         "post-reason" => ["post-user", "post-reason"],
264                         "private" => ["post-user", "private"],
265                         "pubmail" => ["post-thread-user", "pubmail"],
266                         "ignored" => ["post-thread-user", "ignored"],
267                         "visible" => ["post-user", "visible"],
268                         "starred" => ["post-thread-user", "starred"],
269                         "unseen" => ["post-thread-user", "unseen"],
270                         "deleted" => ["post-user", "deleted"],
271                         "origin" => ["post-thread-user", "origin"],
272                         "mention" => ["post-thread-user", "mention"],
273                         "global" => ["post-user", "global"],
274                         "featured" => "EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`)",
275                         "network" => ["post-thread-user", "network"],
276                         "vid" => ["post-user", "vid"],
277                         "psid" => ["post-thread-user", "psid"],
278                         "verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
279                         "title" => ["post-content", "title"],
280                         "content-warning" => ["post-content", "content-warning"],
281                         "raw-body" => ["post-content", "raw-body"],
282                         "body" => ["post-content", "body"],
283                         "rendered-hash" => ["post-content", "rendered-hash"],
284                         "rendered-html" => ["post-content", "rendered-html"],
285                         "language" => ["post-content", "language"],
286                         "plink" => ["post-content", "plink"],
287                         "location" => ["post-content", "location"],
288                         "coord" => ["post-content", "coord"],
289                         "app" => ["post-content", "app"],
290                         "object-type" => ["post-content", "object-type"],
291                         "object" => ["post-content", "object"],
292                         "target-type" => ["post-content", "target-type"],
293                         "target" => ["post-content", "target"],
294                         "resource-id" => ["post-content", "resource-id"],
295                         "contact-id" => ["post-thread-user", "contact-id"],
296                         "contact-uri-id" => ["contact", "uri-id"],
297                         "contact-link" => ["contact", "url"],
298                         "contact-addr" => ["contact", "addr"],
299                         "contact-name" => ["contact", "name"],
300                         "contact-nick" => ["contact", "nick"],
301                         "contact-avatar" => ["contact", "thumb"],
302                         "contact-network" => ["contact", "network"],
303                         "contact-blocked" => ["contact", "blocked"],
304                         "contact-hidden" => ["contact", "hidden"],
305                         "contact-readonly" => ["contact", "readonly"],
306                         "contact-archive" => ["contact", "archive"],
307                         "contact-pending" => ["contact", "pending"],
308                         "contact-rel" => ["contact", "rel"],
309                         "contact-uid" => ["contact", "uid"],
310                         "contact-contact-type" => ["contact", "contact-type"],
311                         "writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
312                         "self" => ["contact", "self"],
313                         "cid" => ["contact", "id"],
314                         "alias" => ["contact", "alias"],
315                         "photo" => ["contact", "photo"],
316                         "name-date" => ["contact", "name-date"],
317                         "uri-date" => ["contact", "uri-date"],
318                         "avatar-date" => ["contact", "avatar-date"],
319                         "thumb" => ["contact", "thumb"],
320                         "author-id" => ["post-thread-user", "author-id"],
321                         "author-uri-id" => ["author", "uri-id"],
322                         "author-link" => ["author", "url"],
323                         "author-addr" => ["author", "addr"],
324                         "author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
325                         "author-nick" => ["author", "nick"],
326                         "author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
327                         "author-network" => ["author", "network"],
328                         "author-blocked" => ["author", "blocked"],
329                         "author-hidden" => ["author", "hidden"],
330                         "author-updated" => ["author", "updated"],
331                         "author-gsid" => ["author", "gsid"],
332                         "author-uri-id" => ["author", "uri-id"],
333                         "owner-id" => ["post-thread-user", "owner-id"],
334                         "owner-uri-id" => ["owner", "uri-id"],
335                         "owner-link" => ["owner", "url"],
336                         "owner-addr" => ["owner", "addr"],
337                         "owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
338                         "owner-nick" => ["owner", "nick"],
339                         "owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
340                         "owner-network" => ["owner", "network"],
341                         "owner-blocked" => ["owner", "blocked"],
342                         "owner-hidden" => ["owner", "hidden"],
343                         "owner-updated" => ["owner", "updated"],
344                         "owner-contact-type" => ["owner", "contact-type"],
345                         "causer-id" => ["post-thread-user", "causer-id"],
346                         "causer-uri-id" => ["causer", "uri-id"],
347                         "causer-link" => ["causer", "url"],
348                         "causer-addr" => ["causer", "addr"],
349                         "causer-name" => ["causer", "name"],
350                         "causer-nick" => ["causer", "nick"],
351                         "causer-avatar" => ["causer", "thumb"],
352                         "causer-network" => ["causer", "network"],
353                         "causer-blocked" => ["causer", "blocked"],
354                         "causer-hidden" => ["causer", "hidden"],
355                         "causer-contact-type" => ["causer", "contact-type"],
356                         "postopts" => ["post-delivery-data", "postopts"],
357                         "inform" => ["post-delivery-data", "inform"],
358                         "delivery_queue_count" => ["post-delivery-data", "queue_count"],
359                         "delivery_queue_done" => ["post-delivery-data", "queue_done"],
360                         "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
361                         "allow_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
362                         "allow_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
363                         "deny_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
364                         "deny_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
365                         "event-id" => ["post-user", "event-id"],
366                         "event-created" => ["event", "created"],
367                         "event-edited" => ["event", "edited"],
368                         "event-start" => ["event", "start"],
369                         "event-finish" => ["event", "finish"],
370                         "event-summary" => ["event", "summary"],
371                         "event-desc" => ["event", "desc"],
372                         "event-location" => ["event", "location"],
373                         "event-type" => ["event", "type"],
374                         "event-nofinish" => ["event", "nofinish"],
375                         "event-ignore" => ["event", "ignore"],
376                         "question-id" => ["post-question", "id"],
377                         "question-multiple" => ["post-question", "multiple"],
378                         "question-voters" => ["post-question", "voters"],
379                         "question-end-time" => ["post-question", "end-time"],
380                         "has-categories" => "EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-thread-user`.`uri-id` AND `post-category`.`uid` = `post-thread-user`.`uid`)",
381                         "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`)",
382                         "signed_text" => ["diaspora-interaction", "interaction"],
383                         "parent-guid" => ["parent-item-uri", "guid"],
384                         "parent-network" => ["parent-post", "network"],
385                         "parent-author-id" => ["parent-post", "author-id"],
386                         "parent-author-link" => ["parent-post-author", "url"],
387                         "parent-author-name" => ["parent-post-author", "name"],
388                         "parent-author-network" => ["parent-post-author", "network"],
389                         "parent-author-blocked" => ["parent-post-author", "blocked"],
390                         "parent-author-hidden" => ["parent-post-author", "hidden"],
391                 ],
392                 "query" => "FROM `post-thread-user`
393                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
394                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
395                         STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
396                         STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
397                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
398                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
399                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
400                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
401                         LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
402                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
403                         LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
404                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
405                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
406                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
407                         LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
408                         LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
409                         LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
410                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-thread-user`.`uid`
411                         LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
412         ],
413         "post-view" => [
414                 "fields" => [
415                         "uri" => ["item-uri", "uri"],
416                         "uri-id" => ["post", "uri-id"],
417                         "parent-uri" => ["parent-item-uri", "uri"],
418                         "parent-uri-id" => ["post", "parent-uri-id"],
419                         "thr-parent" => ["thr-parent-item-uri", "uri"],
420                         "thr-parent-id" => ["post", "thr-parent-id"],
421                         "conversation" => ["conversation-item-uri", "uri"],
422                         "conversation-id" => ["post-thread", "conversation-id"],
423                         "guid" => ["item-uri", "guid"],
424                         "gravity" => ["post", "gravity"],
425                         "extid" => ["external-item-uri", "uri"],
426                         "external-id" => ["post", "external-id"],
427                         "created" => ["post", "created"],
428                         "edited" => ["post", "edited"],
429                         "commented" => ["post-thread", "commented"],
430                         "received" => ["post", "received"],
431                         "changed" => ["post-thread", "changed"],
432                         "post-type" => ["post", "post-type"],
433                         "private" => ["post", "private"],
434                         "visible" => ["post", "visible"],
435                         "deleted" => ["post", "deleted"],
436                         "global" => ["post", "global"],
437                         "featured" => "EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post`.`uri-id`)",
438                         "network" => ["post", "network"],
439                         "vid" => ["post", "vid"],
440                         "verb" => "IF (`post`.`vid` IS NULL, '', `verb`.`name`)",
441                         "title" => ["post-content", "title"],
442                         "content-warning" => ["post-content", "content-warning"],
443                         "raw-body" => ["post-content", "raw-body"],
444                         "body" => ["post-content", "body"],
445                         "rendered-hash" => ["post-content", "rendered-hash"],
446                         "rendered-html" => ["post-content", "rendered-html"],
447                         "language" => ["post-content", "language"],
448                         "plink" => ["post-content", "plink"],
449                         "location" => ["post-content", "location"],
450                         "coord" => ["post-content", "coord"],
451                         "app" => ["post-content", "app"],
452                         "object-type" => ["post-content", "object-type"],
453                         "object" => ["post-content", "object"],
454                         "target-type" => ["post-content", "target-type"],
455                         "target" => ["post-content", "target"],
456                         "resource-id" => ["post-content", "resource-id"],
457                         "contact-id" => ["post", "author-id"],
458                         "contact-uri-id" => ["author", "uri-id"],
459                         "contact-link" => ["author", "url"],
460                         "contact-addr" => ["author", "addr"],
461                         "contact-name" => ["author", "name"],
462                         "contact-nick" => ["author", "nick"],
463                         "contact-avatar" => ["author", "thumb"],
464                         "contact-network" => ["author", "network"],
465                         "contact-blocked" => ["author", "blocked"],
466                         "contact-hidden" => ["author", "hidden"],
467                         "contact-readonly" => ["author", "readonly"],
468                         "contact-archive" => ["author", "archive"],
469                         "contact-pending" => ["author", "pending"],
470                         "contact-rel" => ["author", "rel"],
471                         "contact-uid" => ["author", "uid"],
472                         "contact-contact-type" => ["author", "contact-type"],
473                         "writable" => "IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`)",
474                         "self" => "false",
475                         "cid" => ["author", "id"],
476                         "alias" => ["author", "alias"],
477                         "photo" => ["author", "photo"],
478                         "name-date" => ["author", "name-date"],
479                         "uri-date" => ["author", "uri-date"],
480                         "avatar-date" => ["author", "avatar-date"],
481                         "thumb" => ["author", "thumb"],
482                         "author-id" => ["post", "author-id"],
483                         "author-uri-id" => ["author", "uri-id"],
484                         "author-link" => ["author", "url"],
485                         "author-addr" => ["author", "addr"],
486                         "author-name" => ["author", "name"],
487                         "author-nick" => ["author", "nick"],
488                         "author-avatar" => ["author", "thumb"],
489                         "author-network" => ["author", "network"],
490                         "author-blocked" => ["author", "blocked"],
491                         "author-hidden" => ["author", "hidden"],
492                         "author-updated" => ["author", "updated"],
493                         "author-gsid" => ["author", "gsid"],
494                         "author-uri-id" => ["author", "uri-id"],
495                         "owner-id" => ["post", "owner-id"],
496                         "owner-uri-id" => ["owner", "uri-id"],
497                         "owner-link" => ["owner", "url"],
498                         "owner-addr" => ["owner", "addr"],
499                         "owner-name" => ["owner", "name"],
500                         "owner-nick" => ["owner", "nick"],
501                         "owner-avatar" => ["owner", "thumb"],
502                         "owner-network" => ["owner", "network"],
503                         "owner-blocked" => ["owner", "blocked"],
504                         "owner-hidden" => ["owner", "hidden"],
505                         "owner-updated" => ["owner", "updated"],
506                         "owner-contact-type" => ["owner", "contact-type"],
507                         "causer-id" => ["post", "causer-id"],
508                         "causer-uri-id" => ["causer", "uri-id"],
509                         "causer-link" => ["causer", "url"],
510                         "causer-addr" => ["causer", "addr"],
511                         "causer-name" => ["causer", "name"],
512                         "causer-nick" => ["causer", "nick"],
513                         "causer-avatar" => ["causer", "thumb"],
514                         "causer-network" => ["causer", "network"],
515                         "causer-blocked" => ["causer", "blocked"],
516                         "causer-hidden" => ["causer", "hidden"],
517                         "causer-contact-type" => ["causer", "contact-type"],
518                         "question-id" => ["post-question", "id"],
519                         "question-multiple" => ["post-question", "multiple"],
520                         "question-voters" => ["post-question", "voters"],
521                         "question-end-time" => ["post-question", "end-time"],
522                         "has-categories" => "0",
523                         "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`)",
524                         "signed_text" => ["diaspora-interaction", "interaction"],
525                         "parent-guid" => ["parent-item-uri", "guid"],
526                         "parent-network" => ["parent-post", "network"],
527                         "parent-author-id" => ["parent-post", "author-id"],
528                         "parent-author-link" => ["parent-post-author", "url"],
529                         "parent-author-name" => ["parent-post-author", "name"],
530                         "parent-author-network" => ["parent-post-author", "network"],
531                         "parent-author-blocked" => ["parent-post-author", "blocked"],
532                         "parent-author-hidden" => ["parent-post-author", "hidden"],
533                 ],
534                 "query" => "FROM `post`
535                         STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
536                         STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
537                         STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
538                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
539                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
540                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
541                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
542                         LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
543                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
544                         LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
545                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
546                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
547                         LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
548                         LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
549                         LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
550         ],
551         "post-thread-view" => [
552                 "fields" => [
553                         "uri" => ["item-uri", "uri"],
554                         "uri-id" => ["post-thread", "uri-id"],
555                         "parent-uri" => ["parent-item-uri", "uri"],
556                         "parent-uri-id" => ["post", "parent-uri-id"],
557                         "thr-parent" => ["thr-parent-item-uri", "uri"],
558                         "thr-parent-id" => ["post", "thr-parent-id"],
559                         "conversation" => ["conversation-item-uri", "uri"],
560                         "conversation-id" => ["post-thread", "conversation-id"],
561                         "guid" => ["item-uri", "guid"],
562                         "gravity" => ["post", "gravity"],
563                         "extid" => ["external-item-uri", "uri"],
564                         "external-id" => ["post", "external-id"],
565                         "created" => ["post-thread", "created"],
566                         "edited" => ["post", "edited"],
567                         "commented" => ["post-thread", "commented"],
568                         "received" => ["post-thread", "received"],
569                         "changed" => ["post-thread", "changed"],
570                         "post-type" => ["post", "post-type"],
571                         "private" => ["post", "private"],
572                         "visible" => ["post", "visible"],
573                         "deleted" => ["post", "deleted"],
574                         "global" => ["post", "global"],
575                         "featured" => "EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread`.`uri-id`)",
576                         "network" => ["post-thread", "network"],
577                         "vid" => ["post", "vid"],
578                         "verb" => "IF (`post`.`vid` IS NULL, '', `verb`.`name`)",
579                         "title" => ["post-content", "title"],
580                         "content-warning" => ["post-content", "content-warning"],
581                         "raw-body" => ["post-content", "raw-body"],
582                         "body" => ["post-content", "body"],
583                         "rendered-hash" => ["post-content", "rendered-hash"],
584                         "rendered-html" => ["post-content", "rendered-html"],
585                         "language" => ["post-content", "language"],
586                         "plink" => ["post-content", "plink"],
587                         "location" => ["post-content", "location"],
588                         "coord" => ["post-content", "coord"],
589                         "app" => ["post-content", "app"],
590                         "object-type" => ["post-content", "object-type"],
591                         "object" => ["post-content", "object"],
592                         "target-type" => ["post-content", "target-type"],
593                         "target" => ["post-content", "target"],
594                         "resource-id" => ["post-content", "resource-id"],
595                         "contact-id" => ["post-thread", "author-id"],
596                         "contact-uri-id" => ["author", "uri-id"],
597                         "contact-link" => ["author", "url"],
598                         "contact-addr" => ["author", "addr"],
599                         "contact-name" => ["author", "name"],
600                         "contact-nick" => ["author", "nick"],
601                         "contact-avatar" => ["author", "thumb"],
602                         "contact-network" => ["author", "network"],
603                         "contact-blocked" => ["author", "blocked"],
604                         "contact-hidden" => ["author", "hidden"],
605                         "contact-readonly" => ["author", "readonly"],
606                         "contact-archive" => ["author", "archive"],
607                         "contact-pending" => ["author", "pending"],
608                         "contact-rel" => ["author", "rel"],
609                         "contact-uid" => ["author", "uid"],
610                         "contact-contact-type" => ["author", "contact-type"],
611                         "writable" => "IF (`post`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `author`.`writable`)",
612                         "self" => "false",
613                         "cid" => ["author", "id"],
614                         "alias" => ["author", "alias"],
615                         "photo" => ["author", "photo"],
616                         "name-date" => ["author", "name-date"],
617                         "uri-date" => ["author", "uri-date"],
618                         "avatar-date" => ["author", "avatar-date"],
619                         "thumb" => ["author", "thumb"],
620                         "author-id" => ["post-thread", "author-id"],
621                         "author-uri-id" => ["author", "uri-id"],
622                         "author-link" => ["author", "url"],
623                         "author-addr" => ["author", "addr"],
624                         "author-name" => ["author", "name"],
625                         "author-nick" => ["author", "nick"],
626                         "author-avatar" => ["author", "thumb"],
627                         "author-network" => ["author", "network"],
628                         "author-blocked" => ["author", "blocked"],
629                         "author-hidden" => ["author", "hidden"],
630                         "author-updated" => ["author", "updated"],
631                         "author-gsid" => ["author", "gsid"],
632                         "author-uri-id" => ["author", "uri-id"],
633                         "owner-id" => ["post-thread", "owner-id"],
634                         "owner-uri-id" => ["owner", "uri-id"],
635                         "owner-link" => ["owner", "url"],
636                         "owner-addr" => ["owner", "addr"],
637                         "owner-name" => ["owner", "name"],
638                         "owner-nick" => ["owner", "nick"],
639                         "owner-avatar" => ["owner", "thumb"],
640                         "owner-network" => ["owner", "network"],
641                         "owner-blocked" => ["owner", "blocked"],
642                         "owner-hidden" => ["owner", "hidden"],
643                         "owner-updated" => ["owner", "updated"],
644                         "owner-contact-type" => ["owner", "contact-type"],
645                         "causer-id" => ["post-thread", "causer-id"],
646                         "causer-uri-id" => ["causer", "uri-id"],
647                         "causer-link" => ["causer", "url"],
648                         "causer-addr" => ["causer", "addr"],
649                         "causer-name" => ["causer", "name"],
650                         "causer-nick" => ["causer", "nick"],
651                         "causer-avatar" => ["causer", "thumb"],
652                         "causer-network" => ["causer", "network"],
653                         "causer-blocked" => ["causer", "blocked"],
654                         "causer-hidden" => ["causer", "hidden"],
655                         "causer-contact-type" => ["causer", "contact-type"],
656                         "question-id" => ["post-question", "id"],
657                         "question-multiple" => ["post-question", "multiple"],
658                         "question-voters" => ["post-question", "voters"],
659                         "question-end-time" => ["post-question", "end-time"],
660                         "has-categories" => "0",
661                         "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`)",
662                         "signed_text" => ["diaspora-interaction", "interaction"],
663                         "parent-guid" => ["parent-item-uri", "guid"],
664                         "parent-network" => ["parent-post", "network"],
665                         "parent-author-id" => ["parent-post", "author-id"],
666                         "parent-author-link" => ["parent-post-author", "url"],
667                         "parent-author-name" => ["parent-post-author", "name"],
668                         "parent-author-network" => ["parent-post-author", "network"],
669                         "parent-author-blocked" => ["parent-post-author", "blocked"],
670                         "parent-author-hidden" => ["parent-post-author", "hidden"],
671                 ],
672                 "query" => "FROM `post-thread`
673                         INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
674                         STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
675                         STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
676                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
677                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread`.`uri-id`
678                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
679                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
680                         LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
681                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
682                         LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
683                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
684                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
685                         LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
686                         LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
687                         LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
688         ],
689         "category-view" => [
690                 "fields" => [
691                         "uri-id" => ["post-category", "uri-id"],
692                         "uid" => ["post-category", "uid"],
693                         "type" => ["post-category", "type"],
694                         "tid" => ["post-category", "tid"],
695                         "name" => ["tag", "name"],
696                         "url" => ["tag", "url"],
697                 ],
698                 "query" => "FROM `post-category`
699                         LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
700         ],
701         "collection-view" => [
702                 "fields" => [
703                         "uri-id" => ["post-collection", "uri-id"],
704                         "type" => ["post-collection", "type"],
705                         "cid" => ["post-collection", "author-id"],
706                         "received" => ["post", "received"],
707                         "created" => ["post", "created"],
708                         "commented" => ["post-thread", "commented"],
709                         "private" => ["post", "private"],
710                         "visible" => ["post", "visible"],
711                         "deleted" => ["post", "deleted"],
712                         "thr-parent-id" => ["post", "thr-parent-id"],
713                         "author-id" => ["post-collection", "author-id"],
714                         "gravity" => ["post", "gravity"],
715                 ],
716                 "query" => "FROM `post-collection`
717                         INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
718                         INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`"
719         ],
720         "tag-view" => [
721                 "fields" => [
722                         "uri-id" => ["post-tag", "uri-id"],
723                         "type" => ["post-tag", "type"],
724                         "tid" => ["post-tag", "tid"],
725                         "cid" => ["post-tag", "cid"],
726                         "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
727                         "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
728                         "tag-type" => "CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END",
729                 ],
730                 "query" => "FROM `post-tag`
731                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
732                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
733         ],
734         "network-item-view" => [
735                 "fields" => [
736                         "uri-id" => ["post-user", "uri-id"],
737                         "parent" => ["parent-post", "id"],
738                         "received" => ["post-user", "received"],
739                         "commented" => ["post-thread-user", "commented"],
740                         "created" => ["post-user", "created"],
741                         "uid" => ["post-user", "uid"],
742                         "starred" => ["post-thread-user", "starred"],
743                         "mention" => ["post-thread-user", "mention"],
744                         "network" => ["post-user", "network"],
745                         "unseen" => ["post-user", "unseen"],
746                         "gravity" => ["post-user", "gravity"],
747                         "contact-id" => ["post-user", "contact-id"],
748                         "contact-type" => ["ownercontact", "contact-type"],
749                 ],
750                 "query" => "FROM `post-user`
751                         STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`                  
752                         INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
753                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
754                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
755                         INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
756                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
757                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
758                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
759                         AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
760                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
761                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
762         ],
763         "network-thread-view" => [
764                 "fields" => [
765                         "uri-id" => ["post-thread-user", "uri-id"],
766                         "parent" => ["parent-post", "id"],
767                         "received" => ["post-thread-user", "received"],
768                         "commented" => ["post-thread-user", "commented"],
769                         "created" => ["post-thread-user", "created"],
770                         "uid" => ["post-thread-user", "uid"],
771                         "starred" => ["post-thread-user", "starred"],
772                         "mention" => ["post-thread-user", "mention"],
773                         "network" => ["post-thread-user", "network"],
774                         "contact-id" => ["post-thread-user", "contact-id"],
775                         "contact-type" => ["ownercontact", "contact-type"],
776                 ],
777                 "query" => "FROM `post-thread-user`
778                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
779                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
780                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
781                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
782                         LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
783                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
784                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
785                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
786                         AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
787                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
788                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
789         ],
790         "owner-view" => [
791                 "fields" => [
792                         "id" => ["contact", "id"],
793                         "uid" => ["contact", "uid"],
794                         "created" => ["contact", "created"],
795                         "updated" => ["contact", "updated"],
796                         "self" => ["contact", "self"],
797                         "remote_self" => ["contact", "remote_self"],
798                         "rel" => ["contact", "rel"],
799                         "network" => ["contact", "network"],
800                         "protocol" => ["contact", "protocol"],
801                         "name" => ["contact", "name"],
802                         "nick" => ["contact", "nick"],
803                         "location" => ["contact", "location"],
804                         "about" => ["contact", "about"],
805                         "keywords" => ["contact", "keywords"],
806                         "xmpp" => ["contact", "xmpp"],
807                         "matrix" => ["contact", "matrix"],
808                         "attag" => ["contact", "attag"],
809                         "avatar" => ["contact", "avatar"],
810                         "photo" => ["contact", "photo"],
811                         "thumb" => ["contact", "thumb"],
812                         "micro" => ["contact", "micro"],
813                         "header" => ["contact", "header"],
814                         "url" => ["contact", "url"],
815                         "nurl" => ["contact", "nurl"],
816                         "uri-id" => ["contact", "uri-id"],
817                         "addr" => ["contact", "addr"],
818                         "alias" => ["contact", "alias"],
819                         "pubkey" => ["contact", "pubkey"],
820                         "prvkey" => ["contact", "prvkey"],
821                         "batch" => ["contact", "batch"],
822                         "request" => ["contact", "request"],
823                         "notify" => ["contact", "notify"],
824                         "poll" => ["contact", "poll"],
825                         "confirm" => ["contact", "confirm"],
826                         "poco" => ["contact", "poco"],
827                         "subhub" => ["contact", "subhub"],
828                         "hub-verify" => ["contact", "hub-verify"],
829                         "last-update" => ["contact", "last-update"],
830                         "success_update" => ["contact", "success_update"],
831                         "failure_update" => ["contact", "failure_update"],
832                         "name-date" => ["contact", "name-date"],
833                         "uri-date" => ["contact", "uri-date"],
834                         "avatar-date" => ["contact", "avatar-date"],
835                         "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
836                         "term-date" => ["contact", "term-date"],
837                         "last-item" => ["contact", "last-item"],
838                         "priority" => ["contact", "priority"],
839                         "blocked" => ["user", "blocked"],
840                         "block_reason" => ["contact", "block_reason"],
841                         "readonly" => ["contact", "readonly"],
842                         "writable" => ["contact", "writable"],
843                         "forum" => ["contact", "forum"],
844                         "prv" => ["contact", "prv"],
845                         "contact-type" => ["contact", "contact-type"],
846                         "manually-approve" => ["contact", "manually-approve"],
847                         "hidden" => ["contact", "hidden"],
848                         "archive" => ["contact", "archive"],
849                         "pending" => ["contact", "pending"],
850                         "deleted" => ["contact", "deleted"],
851                         "unsearchable" => ["contact", "unsearchable"],
852                         "sensitive" => ["contact", "sensitive"],
853                         "baseurl" => ["contact", "baseurl"],
854                         "reason" => ["contact", "reason"],
855                         "info" => ["contact", "info"],
856                         "bdyear" => ["contact", "bdyear"],
857                         "bd" => ["contact", "bd"],
858                         "notify_new_posts" => ["contact", "notify_new_posts"],
859                         "fetch_further_information" => ["contact", "fetch_further_information"],
860                         "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
861                         "parent-uid" => ["user", "parent-uid"],
862                         "guid" => ["user", "guid"],
863                         "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
864                         "email" => ["user", "email"],
865                         "openid" => ["user", "openid"],
866                         "timezone" => ["user", "timezone"],
867                         "language" => ["user", "language"],
868                         "register_date" => ["user", "register_date"],
869                         "login_date" => ["user", "login_date"],
870                         "default-location" => ["user", "default-location"],
871                         "allow_location" => ["user", "allow_location"],
872                         "theme" => ["user", "theme"],
873                         "upubkey" => ["user", "pubkey"],
874                         "uprvkey" => ["user", "prvkey"],
875                         "sprvkey" => ["user", "sprvkey"],
876                         "spubkey" => ["user", "spubkey"],
877                         "verified" => ["user", "verified"],
878                         "blockwall" => ["user", "blockwall"],
879                         "hidewall" => ["user", "hidewall"],
880                         "blocktags" => ["user", "blocktags"],
881                         "unkmail" => ["user", "unkmail"],
882                         "cntunkmail" => ["user", "cntunkmail"],
883                         "notify-flags" => ["user", "notify-flags"],
884                         "page-flags" => ["user", "page-flags"],
885                         "account-type" => ["user", "account-type"],
886                         "prvnets" => ["user", "prvnets"],
887                         "maxreq" => ["user", "maxreq"],
888                         "expire" => ["user", "expire"],
889                         "account_removed" => ["user", "account_removed"],
890                         "account_expired" => ["user", "account_expired"],
891                         "account_expires_on" => ["user", "account_expires_on"],
892                         "expire_notification_sent" => ["user", "expire_notification_sent"],
893                         "def_gid" => ["user", "def_gid"],
894                         "allow_cid" => ["user", "allow_cid"],
895                         "allow_gid" => ["user", "allow_gid"],
896                         "deny_cid" => ["user", "deny_cid"],
897                         "deny_gid" => ["user", "deny_gid"],
898                         "openidserver" => ["user", "openidserver"],
899                         "publish" => ["profile", "publish"],
900                         "net-publish" => ["profile", "net-publish"],
901                         "hide-friends" => ["profile", "hide-friends"],
902                         "prv_keywords" => ["profile", "prv_keywords"],
903                         "pub_keywords" => ["profile", "pub_keywords"],
904                         "address" => ["profile", "address"],
905                         "locality" => ["profile", "locality"],
906                         "region" => ["profile", "region"],
907                         "postal-code" => ["profile", "postal-code"],
908                         "country-name" => ["profile", "country-name"],
909                         "homepage" => ["profile", "homepage"],
910                         "dob" => ["profile", "dob"],
911                 ],
912                 "query" => "FROM `user`
913                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
914                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
915         ],
916         "account-view" => [
917                 "fields" => [
918                         "id" => ["contact", "id"],
919                         "url" => ["contact", "url"],
920                         "nurl" => ["contact", "nurl"],
921                         "uri-id" => ["contact", "uri-id"],
922                         "guid" => ["item-uri", "guid"],
923                         "addr" => ["contact", "addr"],
924                         "alias" => ["contact", "alias"],
925                         "name" => ["contact", "name"],
926                         "nick" => ["contact", "nick"],
927                         "about" => ["contact", "about"],
928                         "keywords" => ["contact", "keywords"],
929                         "xmpp" => ["contact", "xmpp"],
930                         "matrix" => ["contact", "matrix"],
931                         "avatar" => ["contact", "avatar"],
932                         "photo" => ["contact", "photo"],
933                         "thumb" => ["contact", "thumb"],
934                         "micro" => ["contact", "micro"],
935                         "header" => ["contact", "header"],
936                         "created" => ["contact", "created"],
937                         "updated" => ["contact", "updated"],
938                         "network" => ["contact", "network"],
939                         "protocol" => ["contact", "protocol"],
940                         "location" => ["contact", "location"],
941                         "attag" => ["contact", "attag"],
942                         "pubkey" => ["contact", "pubkey"],
943                         "prvkey" => ["contact", "prvkey"],
944                         "subscribe" => ["contact", "subscribe"],
945                         "last-update" => ["contact", "last-update"],
946                         "success_update" => ["contact", "success_update"],
947                         "failure_update" => ["contact", "failure_update"],
948                         "failed" => ["contact", "failed"],
949                         "last-item" => ["contact", "last-item"],
950                         "last-discovery" => ["contact", "last-discovery"],
951                         "contact-type" => ["contact", "contact-type"],
952                         "manually-approve" => ["contact", "manually-approve"],
953                         "unsearchable" => ["contact", "unsearchable"],
954                         "sensitive" => ["contact", "sensitive"],
955                         "baseurl" => ["contact", "baseurl"],
956                         "gsid" => ["contact", "gsid"],
957                         "info" => ["contact", "info"],
958                         "bdyear" => ["contact", "bdyear"],
959                         "bd" => ["contact", "bd"],
960                         "poco" => ["contact", "poco"],
961                         "name-date" => ["contact", "name-date"],
962                         "uri-date" => ["contact", "uri-date"],
963                         "avatar-date" => ["contact", "avatar-date"],
964                         "term-date" => ["contact", "term-date"],
965                         "global-ignored" => ["contact", "hidden"],
966                         "global-blocked" => ["contact", "blocked"],
967                         "hidden" => ["contact", "hidden"],
968                         "archive" => ["contact", "archive"],
969                         "deleted" => ["contact", "deleted"],
970                         "blocked" => ["contact", "blocked"],
971                         "dfrn-notify" => ["contact", "notify"],
972                         "dfrn-poll" => ["contact", "poll"],
973                         "diaspora-guid" => ["fcontact", "guid"],
974                         "diaspora-batch" => ["fcontact", "batch"],
975                         "diaspora-notify" => ["fcontact", "notify"],
976                         "diaspora-poll" => ["fcontact", "poll"],
977                         "diaspora-alias" => ["fcontact", "alias"],
978                         "ap-uuid" => ["apcontact", "uuid"],
979                         "ap-type" => ["apcontact", "type"],
980                         "ap-following" => ["apcontact", "following"],
981                         "ap-followers" => ["apcontact", "followers"],
982                         "ap-inbox" => ["apcontact", "inbox"],
983                         "ap-outbox" => ["apcontact", "outbox"],
984                         "ap-sharedinbox" => ["apcontact", "sharedinbox"],
985                         "ap-generator" => ["apcontact", "generator"],
986                         "ap-following_count" => ["apcontact", "following_count"],
987                         "ap-followers_count" => ["apcontact", "followers_count"],
988                         "ap-statuses_count" => ["apcontact", "statuses_count"],
989                         "site_name" => ["gserver", "site_name"],
990                         "platform" => ["gserver", "platform"],
991                         "version" => ["gserver", "version"],
992                 ],
993                 "query" => "FROM `contact`
994                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
995                         LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
996                         LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
997                         LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
998                         WHERE `contact`.`uid` = 0"                      
999         ],
1000         "account-user-view" => [
1001                 "fields" => [
1002                         "id" => ["ucontact", "id"],
1003                         "pid" => ["contact", "id"],
1004                         "uid" => ["ucontact", "uid"],
1005                         "url" => ["contact", "url"],
1006                         "nurl" => ["contact", "nurl"],
1007                         "uri-id" => ["contact", "uri-id"],
1008                         "guid" => ["item-uri", "guid"],
1009                         "addr" => ["contact", "addr"],
1010                         "alias" => ["contact", "alias"],
1011                         "name" => ["contact", "name"],
1012                         "nick" => ["contact", "nick"],
1013                         "about" => ["contact", "about"],
1014                         "keywords" => ["contact", "keywords"],
1015                         "xmpp" => ["contact", "xmpp"],
1016                         "matrix" => ["contact", "matrix"],
1017                         "avatar" => ["contact", "avatar"],
1018                         "photo" => ["contact", "photo"],
1019                         "thumb" => ["contact", "thumb"],
1020                         "micro" => ["contact", "micro"],
1021                         "header" => ["contact", "header"],
1022                         "created" => ["contact", "created"],
1023                         "updated" => ["contact", "updated"],
1024                         "self" => ["ucontact", "self"],
1025                         "remote_self" => ["ucontact", "remote_self"],
1026                         "rel" =>  ["ucontact", "rel"],
1027                         "network" => ["contact", "network"],
1028                         "protocol" => ["ucontact", "protocol"],
1029                         "location" => ["contact", "location"],
1030                         "attag" => ["ucontact", "attag"],
1031                         "pubkey" => ["contact", "pubkey"],
1032                         "prvkey" => ["contact", "prvkey"],
1033                         "subscribe" => ["contact", "subscribe"],
1034                         "last-update" => ["contact", "last-update"],
1035                         "success_update" => ["contact", "success_update"],
1036                         "failure_update" => ["contact", "failure_update"],
1037                         "failed" => ["contact", "failed"],
1038                         "last-item" => ["contact", "last-item"],
1039                         "last-discovery" => ["contact", "last-discovery"],
1040                         "contact-type" => ["contact", "contact-type"],
1041                         "manually-approve" => ["contact", "manually-approve"],
1042                         "unsearchable" => ["contact", "unsearchable"],
1043                         "sensitive" => ["contact", "sensitive"],
1044                         "baseurl" => ["contact", "baseurl"],
1045                         "gsid" => ["contact", "gsid"],
1046                         "info" => ["ucontact", "info"],
1047                         "bdyear" => ["contact", "bdyear"],
1048                         "bd" => ["contact", "bd"],
1049                         "poco" => ["contact", "poco"],
1050                         "name-date" => ["contact", "name-date"],
1051                         "uri-date" => ["contact", "uri-date"],
1052                         "avatar-date" => ["contact", "avatar-date"],
1053                         "term-date" => ["contact", "term-date"],
1054                         "global-ignored" => ["contact", "hidden"],
1055                         "global-blocked" => ["contact", "blocked"],
1056                         "hidden" => ["ucontact", "hidden"],
1057                         "archive" => ["ucontact", "archive"],
1058                         "pending" => ["ucontact", "pending"],
1059                         "deleted" => ["ucontact", "deleted"],
1060                         "notify_new_posts" => ["ucontact", "notify_new_posts"],
1061                         "fetch_further_information" => ["ucontact", "fetch_further_information"],
1062                         "ffi_keyword_denylist" => ["ucontact", "ffi_keyword_denylist"],
1063                         "rating" => ["ucontact", "rating"],
1064                         "readonly" => ["ucontact", "readonly"],
1065                         "blocked" => ["ucontact", "blocked"],
1066                         "block_reason" => ["ucontact", "block_reason"],
1067                         "subhub" => ["ucontact", "subhub"],
1068                         "hub-verify" => ["ucontact", "hub-verify"],
1069                         "reason" => ["ucontact", "reason"],
1070                         "dfrn-notify" => ["contact", "notify"],
1071                         "dfrn-poll" => ["contact", "poll"],
1072                         "diaspora-guid" => ["fcontact", "guid"],
1073                         "diaspora-batch" => ["fcontact", "batch"],
1074                         "diaspora-notify" => ["fcontact", "notify"],
1075                         "diaspora-poll" => ["fcontact", "poll"],
1076                         "diaspora-alias" => ["fcontact", "alias"],
1077                         "diaspora-interacting_count" => ["fcontact", "interacting_count"],
1078                         "diaspora-interacted_count" => ["fcontact", "interacted_count"],
1079                         "diaspora-post_count" => ["fcontact", "post_count"],
1080                         "ap-uuid" => ["apcontact", "uuid"],
1081                         "ap-type" => ["apcontact", "type"],
1082                         "ap-following" => ["apcontact", "following"],
1083                         "ap-followers" => ["apcontact", "followers"],
1084                         "ap-inbox" => ["apcontact", "inbox"],
1085                         "ap-outbox" => ["apcontact", "outbox"],
1086                         "ap-sharedinbox" => ["apcontact", "sharedinbox"],
1087                         "ap-generator" => ["apcontact", "generator"],
1088                         "ap-following_count" => ["apcontact", "following_count"],
1089                         "ap-followers_count" => ["apcontact", "followers_count"],
1090                         "ap-statuses_count" => ["apcontact", "statuses_count"],
1091                         "site_name" => ["gserver", "site_name"],
1092                         "platform" => ["gserver", "platform"],
1093                         "version" => ["gserver", "version"],
1094                 ],
1095                 "query" => "FROM `contact` AS `ucontact`
1096                         INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
1097                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
1098                         LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
1099                         LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
1100                         LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`"
1101         ],
1102         "pending-view" => [
1103                 "fields" => [
1104                         "id" => ["register", "id"],
1105                         "hash" => ["register", "hash"],
1106                         "created" => ["register", "created"],
1107                         "uid" => ["register", "uid"],
1108                         "password" => ["register", "password"],
1109                         "language" => ["register", "language"],
1110                         "note" => ["register", "note"],
1111                         "self" => ["contact", "self"],
1112                         "name" => ["contact", "name"],
1113                         "url" => ["contact", "url"],
1114                         "micro" => ["contact", "micro"],
1115                         "email" => ["user", "email"],
1116                         "nick" => ["contact", "nick"],
1117                 ],
1118                 "query" => "FROM `register`
1119                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1120                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
1121         ],
1122         "tag-search-view" => [
1123                 "fields" => [
1124                         "uri-id" => ["post-tag", "uri-id"],
1125                         "uid" => ["post-user", "uid"],
1126                         "iid" => ["post-user", "id"],
1127                         "private" => ["post-user", "private"],
1128                         "wall" => ["post-user", "wall"],
1129                         "origin" => ["post-user", "origin"],
1130                         "global" => ["post-user", "global"],
1131                         "gravity" => ["post-user", "gravity"],
1132                         "received" => ["post-user", "received"],
1133                         "network" => ["post-user", "network"],
1134                         "author-id" => ["post-user", "author-id"],
1135                         "name" => ["tag", "name"],
1136                 ],
1137                 "query" => "FROM `post-tag`
1138                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1139                         STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
1140                         WHERE `post-tag`.`type` = 1"
1141         ],
1142         "workerqueue-view" => [
1143                 "fields" => [
1144                         "pid" => ["process", "pid"],
1145                         "priority" => ["workerqueue", "priority"],
1146                 ],
1147                 "query" => "FROM `process`
1148                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1149                         WHERE NOT `workerqueue`.`done`"
1150         ],
1151         "profile_field-view" => [
1152                 "fields" => [
1153                         "id" => ["profile_field", "id"],
1154                         "uid" => ["profile_field", "uid"],
1155                         "label" => ["profile_field", "label"],
1156                         "value" => ["profile_field", "value"],
1157                         "order" => ["profile_field", "order"],
1158                         "psid"=> ["profile_field", "psid"],
1159                         "allow_cid" => ["permissionset", "allow_cid"],
1160                         "allow_gid" => ["permissionset", "allow_gid"],
1161                         "deny_cid" => ["permissionset", "deny_cid"],
1162                         "deny_gid" => ["permissionset", "deny_gid"],
1163                         "created" => ["profile_field", "created"],
1164                         "edited" => ["profile_field", "edited"],
1165                 ],
1166                 "query" => "FROM `profile_field`
1167                         INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`"
1168         ],
1169 ];
1170