]> git.mxchange.org Git - friendica.git/blob - static/dbview.config.php
b960cfaf3d8cc280edae015df7af3b2e64b73b76
[friendica.git] / static / dbview.config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, 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" => ["post-thread-user", "post-user-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                         "quote-uri" => ["quote-item-uri", "uri"],
76                         "quote-uri-id" => ["post-content", "quote-uri-id"],
77                         "guid" => ["item-uri", "guid"],
78                         "wall" => ["post-user", "wall"],
79                         "gravity" => ["post-user", "gravity"],
80                         "extid" => ["external-item-uri", "uri"],
81                         "external-id" => ["post-user", "external-id"],
82                         "created" => ["post-user", "created"],
83                         "edited" => ["post-user", "edited"],
84                         "commented" => ["post-thread-user", "commented"],
85                         "received" => ["post-user", "received"],
86                         "changed" => ["post-thread-user", "changed"],
87                         "post-type" => ["post-user", "post-type"],
88                         "post-reason" => ["post-user", "post-reason"],
89                         "private" => ["post-user", "private"],
90                         "pubmail" => ["post-thread-user", "pubmail"],
91                         "visible" => ["post-user", "visible"],
92                         "starred" => ["post-thread-user", "starred"],
93                         "unseen" => ["post-user", "unseen"],
94                         "deleted" => ["post-user", "deleted"],
95                         "origin" => ["post-user", "origin"],
96                         "parent-origin" => ["post-thread-user", "origin"],
97                         "mention" => ["post-thread-user", "mention"],
98                         "global" => ["post-user", "global"],
99                         "featured" => "EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-user`.`uri-id`)",
100                         "network" => ["post-user", "network"],
101                         "protocol" => ["post-user", "protocol"],
102                         "vid" => ["post-user", "vid"],
103                         "psid" => ["post-user", "psid"],
104                         "verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
105                         "title" => ["post-content", "title"],
106                         "content-warning" => ["post-content", "content-warning"],
107                         "raw-body" => ["post-content", "raw-body"],
108                         "body" => "IFNULL (`post-content`.`body`, '')",
109                         "rendered-hash" => ["post-content", "rendered-hash"],
110                         "rendered-html" => ["post-content", "rendered-html"],
111                         "language" => ["post-content", "language"],
112                         "plink" => ["post-content", "plink"],
113                         "location" => ["post-content", "location"],
114                         "coord" => ["post-content", "coord"],
115                         "app" => ["post-content", "app"],
116                         "object-type" => ["post-content", "object-type"],
117                         "object" => ["post-content", "object"],
118                         "target-type" => ["post-content", "target-type"],
119                         "target" => ["post-content", "target"],
120                         "resource-id" => ["post-content", "resource-id"],
121                         "contact-id" => ["post-user", "contact-id"],
122                         "contact-uri-id" => ["contact", "uri-id"],
123                         "contact-link" => ["contact", "url"],
124                         "contact-addr" => ["contact", "addr"],
125                         "contact-name" => ["contact", "name"],
126                         "contact-nick" => ["contact", "nick"],
127                         "contact-avatar" => ["contact", "thumb"],
128                         "contact-network" => ["contact", "network"],
129                         "contact-blocked" => ["contact", "blocked"],
130                         "contact-hidden" => ["contact", "hidden"],
131                         "contact-readonly" => ["contact", "readonly"],
132                         "contact-archive" => ["contact", "archive"],
133                         "contact-pending" => ["contact", "pending"],
134                         "contact-rel" => ["contact", "rel"],
135                         "contact-uid" => ["contact", "uid"],
136                         "contact-contact-type" => ["contact", "contact-type"],
137                         "writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
138                         "self" => ["contact", "self"],
139                         "cid" => ["contact", "id"],
140                         "alias" => ["contact", "alias"],
141                         "photo" => ["contact", "photo"],
142                         "name-date" => ["contact", "name-date"],
143                         "uri-date" => ["contact", "uri-date"],
144                         "avatar-date" => ["contact", "avatar-date"],
145                         "thumb" => ["contact", "thumb"],
146                         "author-id" => ["post-user", "author-id"],
147                         "author-uri-id" => ["author", "uri-id"],
148                         "author-link" => ["author", "url"],
149                         "author-addr" => ["author", "addr"],
150                         "author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
151                         "author-nick" => ["author", "nick"],
152                         "author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
153                         "author-network" => ["author", "network"],
154                         "author-blocked" => ["author", "blocked"],
155                         "author-hidden" => ["author", "hidden"],
156                         "author-updated" => ["author", "updated"],
157                         "author-gsid" => ["author", "gsid"],
158                         "owner-id" => ["post-user", "owner-id"],
159                         "owner-uri-id" => ["owner", "uri-id"],
160                         "owner-link" => ["owner", "url"],
161                         "owner-addr" => ["owner", "addr"],
162                         "owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
163                         "owner-nick" => ["owner", "nick"],
164                         "owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
165                         "owner-network" => ["owner", "network"],
166                         "owner-blocked" => ["owner", "blocked"],
167                         "owner-hidden" => ["owner", "hidden"],
168                         "owner-updated" => ["owner", "updated"],
169                         "owner-contact-type" => ["owner", "contact-type"],
170                         "causer-id" => ["post-user", "causer-id"],
171                         "causer-uri-id" => ["causer", "uri-id"],
172                         "causer-link" => ["causer", "url"],
173                         "causer-addr" => ["causer", "addr"],
174                         "causer-name" => ["causer", "name"],
175                         "causer-nick" => ["causer", "nick"],
176                         "causer-avatar" => ["causer", "thumb"],
177                         "causer-network" => ["causer", "network"],
178                         "causer-blocked" => ["causer", "blocked"],
179                         "causer-hidden" => ["causer", "hidden"],
180                         "causer-contact-type" => ["causer", "contact-type"],
181                         "postopts" => ["post-delivery-data", "postopts"],
182                         "inform" => ["post-delivery-data", "inform"],
183                         "delivery_queue_count" => ["post-delivery-data", "queue_count"],
184                         "delivery_queue_done" => ["post-delivery-data", "queue_done"],
185                         "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
186                         "allow_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
187                         "allow_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
188                         "deny_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
189                         "deny_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
190                         "event-id" => ["post-user", "event-id"],
191                         "event-created" => ["event", "created"],
192                         "event-edited" => ["event", "edited"],
193                         "event-start" => ["event", "start"],
194                         "event-finish" => ["event", "finish"],
195                         "event-summary" => ["event", "summary"],
196                         "event-desc" => ["event", "desc"],
197                         "event-location" => ["event", "location"],
198                         "event-type" => ["event", "type"],
199                         "event-nofinish" => ["event", "nofinish"],
200                         "event-ignore" => ["event", "ignore"],
201                         "question-id" => ["post-question", "id"],
202                         "question-multiple" => ["post-question", "multiple"],
203                         "question-voters" => ["post-question", "voters"],
204                         "question-end-time" => ["post-question", "end-time"],
205                         "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`)",
206                         "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`)",
207                         "signed_text" => ["diaspora-interaction", "interaction"],
208                         "parent-guid" => ["parent-item-uri", "guid"],
209                         "parent-network" => ["post-thread-user", "network"],
210                         "parent-author-id" => ["post-thread-user", "author-id"],
211                         "parent-author-link" => ["parent-post-author", "url"],
212                         "parent-author-name" => ["parent-post-author", "name"],
213                         "parent-author-nick" => ["parent-post-author", "nick"],
214                         "parent-author-network" => ["parent-post-author", "network"],
215                 ],
216                 "query" => "FROM `post-user`
217                         INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
218                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
219                         STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
220                         STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
221                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
222                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
223                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
224                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
225                         LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
226                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
227                         LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
228                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
229                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
230                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
231                         LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-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 `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread-user`.`author-id`"
236         ],
237         "post-thread-user-view" => [
238                 "fields" => [
239                         "id" => ["post-user", "id"],
240                         "post-user-id" => ["post-user", "id"],
241                         "uid" => ["post-thread-user", "uid"],
242                         "parent" => ["post-thread-user", "post-user-id"],
243                         "uri" => ["item-uri", "uri"],
244                         "uri-id" => ["post-thread-user", "uri-id"],
245                         "parent-uri" => ["parent-item-uri", "uri"],
246                         "parent-uri-id" => ["post-user", "parent-uri-id"],
247                         "thr-parent" => ["thr-parent-item-uri", "uri"],
248                         "thr-parent-id" => ["post-user", "thr-parent-id"],
249                         "conversation" => ["conversation-item-uri", "uri"],
250                         "conversation-id" => ["post-thread-user", "conversation-id"],
251                         "quote-uri" => ["quote-item-uri", "uri"],
252                         "quote-uri-id" => ["post-content", "quote-uri-id"],
253                         "guid" => ["item-uri", "guid"],
254                         "wall" => ["post-thread-user", "wall"],
255                         "gravity" => ["post-user", "gravity"],
256                         "extid" => ["external-item-uri", "uri"],
257                         "external-id" => ["post-user", "external-id"],
258                         "created" => ["post-thread-user", "created"],
259                         "edited" => ["post-user", "edited"],
260                         "commented" => ["post-thread-user", "commented"],
261                         "received" => ["post-thread-user", "received"],
262                         "changed" => ["post-thread-user", "changed"],
263                         "post-type" => ["post-user", "post-type"],
264                         "post-reason" => ["post-user", "post-reason"],
265                         "private" => ["post-user", "private"],
266                         "pubmail" => ["post-thread-user", "pubmail"],
267                         "ignored" => ["post-thread-user", "ignored"],
268                         "visible" => ["post-user", "visible"],
269                         "starred" => ["post-thread-user", "starred"],
270                         "unseen" => ["post-thread-user", "unseen"],
271                         "deleted" => ["post-user", "deleted"],
272                         "origin" => ["post-thread-user", "origin"],
273                         "mention" => ["post-thread-user", "mention"],
274                         "global" => ["post-user", "global"],
275                         "featured" => "EXISTS(SELECT `type` FROM `post-collection` WHERE `type` = 0 AND `uri-id` = `post-thread-user`.`uri-id`)",
276                         "network" => ["post-thread-user", "network"],
277                         "vid" => ["post-user", "vid"],
278                         "psid" => ["post-thread-user", "psid"],
279                         "verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
280                         "title" => ["post-content", "title"],
281                         "content-warning" => ["post-content", "content-warning"],
282                         "raw-body" => ["post-content", "raw-body"],
283                         "body" => ["post-content", "body"],
284                         "rendered-hash" => ["post-content", "rendered-hash"],
285                         "rendered-html" => ["post-content", "rendered-html"],
286                         "language" => ["post-content", "language"],
287                         "plink" => ["post-content", "plink"],
288                         "location" => ["post-content", "location"],
289                         "coord" => ["post-content", "coord"],
290                         "app" => ["post-content", "app"],
291                         "object-type" => ["post-content", "object-type"],
292                         "object" => ["post-content", "object"],
293                         "target-type" => ["post-content", "target-type"],
294                         "target" => ["post-content", "target"],
295                         "resource-id" => ["post-content", "resource-id"],
296                         "contact-id" => ["post-thread-user", "contact-id"],
297                         "contact-uri-id" => ["contact", "uri-id"],
298                         "contact-link" => ["contact", "url"],
299                         "contact-addr" => ["contact", "addr"],
300                         "contact-name" => ["contact", "name"],
301                         "contact-nick" => ["contact", "nick"],
302                         "contact-avatar" => ["contact", "thumb"],
303                         "contact-network" => ["contact", "network"],
304                         "contact-blocked" => ["contact", "blocked"],
305                         "contact-hidden" => ["contact", "hidden"],
306                         "contact-readonly" => ["contact", "readonly"],
307                         "contact-archive" => ["contact", "archive"],
308                         "contact-pending" => ["contact", "pending"],
309                         "contact-rel" => ["contact", "rel"],
310                         "contact-uid" => ["contact", "uid"],
311                         "contact-contact-type" => ["contact", "contact-type"],
312                         "writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
313                         "self" => ["contact", "self"],
314                         "cid" => ["contact", "id"],
315                         "alias" => ["contact", "alias"],
316                         "photo" => ["contact", "photo"],
317                         "name-date" => ["contact", "name-date"],
318                         "uri-date" => ["contact", "uri-date"],
319                         "avatar-date" => ["contact", "avatar-date"],
320                         "thumb" => ["contact", "thumb"],
321                         "author-id" => ["post-thread-user", "author-id"],
322                         "author-uri-id" => ["author", "uri-id"],
323                         "author-link" => ["author", "url"],
324                         "author-addr" => ["author", "addr"],
325                         "author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
326                         "author-nick" => ["author", "nick"],
327                         "author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
328                         "author-network" => ["author", "network"],
329                         "author-blocked" => ["author", "blocked"],
330                         "author-hidden" => ["author", "hidden"],
331                         "author-updated" => ["author", "updated"],
332                         "author-gsid" => ["author", "gsid"],
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" => ["post-thread-user", "network"],
385                         "parent-author-id" => ["post-thread-user", "author-id"],
386                         "parent-author-link" => ["author", "url"],
387                         "parent-author-name" => ["author", "name"],
388                         "parent-author-nick" => ["author", "nick"],
389                         "parent-author-network" => ["author", "network"],
390                 ],
391                 "query" => "FROM `post-thread-user`
392                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
393                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
394                         STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
395                         STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
396                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
397                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
398                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
399                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
400                         LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread-user`.`conversation-id`
401                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
402                         LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
403                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
404                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
405                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
406                         LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-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         ],
411         "post-view" => [
412                 "fields" => [
413                         "uri" => ["item-uri", "uri"],
414                         "uri-id" => ["post", "uri-id"],
415                         "parent-uri" => ["parent-item-uri", "uri"],
416                         "parent-uri-id" => ["post", "parent-uri-id"],
417                         "thr-parent" => ["thr-parent-item-uri", "uri"],
418                         "thr-parent-id" => ["post", "thr-parent-id"],
419                         "conversation" => ["conversation-item-uri", "uri"],
420                         "conversation-id" => ["post-thread", "conversation-id"],
421                         "quote-uri" => ["quote-item-uri", "uri"],
422                         "quote-uri-id" => ["post-content", "quote-uri-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                         "owner-id" => ["post", "owner-id"],
495                         "owner-uri-id" => ["owner", "uri-id"],
496                         "owner-link" => ["owner", "url"],
497                         "owner-addr" => ["owner", "addr"],
498                         "owner-name" => ["owner", "name"],
499                         "owner-nick" => ["owner", "nick"],
500                         "owner-avatar" => ["owner", "thumb"],
501                         "owner-network" => ["owner", "network"],
502                         "owner-blocked" => ["owner", "blocked"],
503                         "owner-hidden" => ["owner", "hidden"],
504                         "owner-updated" => ["owner", "updated"],
505                         "owner-contact-type" => ["owner", "contact-type"],
506                         "causer-id" => ["post", "causer-id"],
507                         "causer-uri-id" => ["causer", "uri-id"],
508                         "causer-link" => ["causer", "url"],
509                         "causer-addr" => ["causer", "addr"],
510                         "causer-name" => ["causer", "name"],
511                         "causer-nick" => ["causer", "nick"],
512                         "causer-avatar" => ["causer", "thumb"],
513                         "causer-network" => ["causer", "network"],
514                         "causer-blocked" => ["causer", "blocked"],
515                         "causer-hidden" => ["causer", "hidden"],
516                         "causer-contact-type" => ["causer", "contact-type"],
517                         "question-id" => ["post-question", "id"],
518                         "question-multiple" => ["post-question", "multiple"],
519                         "question-voters" => ["post-question", "voters"],
520                         "question-end-time" => ["post-question", "end-time"],
521                         "has-categories" => "0",
522                         "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`)",
523                         "signed_text" => ["diaspora-interaction", "interaction"],
524                         "parent-guid" => ["parent-item-uri", "guid"],
525                         "parent-network" => ["post-thread", "network"],
526                         "parent-author-id" => ["post-thread", "author-id"],
527                         "parent-author-link" => ["parent-post-author", "url"],
528                         "parent-author-name" => ["parent-post-author", "name"],
529                         "parent-author-nick" => ["parent-post-author", "nick"],
530                         "parent-author-network" => ["parent-post-author", "network"],
531                 ],
532                 "query" => "FROM `post`
533                         STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
534                         STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
535                         STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post`.`owner-id`
536                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post`.`causer-id`
537                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post`.`uri-id`
538                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post`.`thr-parent-id`
539                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post`.`parent-uri-id`
540                         LEFT JOIN `item-uri` AS `conversation-item-uri` ON `conversation-item-uri`.`id` = `post-thread`.`conversation-id`
541                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post`.`external-id`
542                         LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
543                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
544                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
545                         LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
546                         LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
547                         LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `post-thread`.`author-id`"
548         ],
549         "post-thread-view" => [
550                 "fields" => [
551                         "uri" => ["item-uri", "uri"],
552                         "uri-id" => ["post-thread", "uri-id"],
553                         "parent-uri" => ["parent-item-uri", "uri"],
554                         "parent-uri-id" => ["post", "parent-uri-id"],
555                         "thr-parent" => ["thr-parent-item-uri", "uri"],
556                         "thr-parent-id" => ["post", "thr-parent-id"],
557                         "conversation" => ["conversation-item-uri", "uri"],
558                         "conversation-id" => ["post-thread", "conversation-id"],
559                         "quote-uri" => ["quote-item-uri", "uri"],
560                         "quote-uri-id" => ["post-content", "quote-uri-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                         "owner-id" => ["post-thread", "owner-id"],
633                         "owner-uri-id" => ["owner", "uri-id"],
634                         "owner-link" => ["owner", "url"],
635                         "owner-addr" => ["owner", "addr"],
636                         "owner-name" => ["owner", "name"],
637                         "owner-nick" => ["owner", "nick"],
638                         "owner-avatar" => ["owner", "thumb"],
639                         "owner-network" => ["owner", "network"],
640                         "owner-blocked" => ["owner", "blocked"],
641                         "owner-hidden" => ["owner", "hidden"],
642                         "owner-updated" => ["owner", "updated"],
643                         "owner-contact-type" => ["owner", "contact-type"],
644                         "causer-id" => ["post-thread", "causer-id"],
645                         "causer-uri-id" => ["causer", "uri-id"],
646                         "causer-link" => ["causer", "url"],
647                         "causer-addr" => ["causer", "addr"],
648                         "causer-name" => ["causer", "name"],
649                         "causer-nick" => ["causer", "nick"],
650                         "causer-avatar" => ["causer", "thumb"],
651                         "causer-network" => ["causer", "network"],
652                         "causer-blocked" => ["causer", "blocked"],
653                         "causer-hidden" => ["causer", "hidden"],
654                         "causer-contact-type" => ["causer", "contact-type"],
655                         "question-id" => ["post-question", "id"],
656                         "question-multiple" => ["post-question", "multiple"],
657                         "question-voters" => ["post-question", "voters"],
658                         "question-end-time" => ["post-question", "end-time"],
659                         "has-categories" => "0",
660                         "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`)",
661                         "total-comments" => "(SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6)",
662                         "total-actors" => "(SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6)",
663                         "signed_text" => ["diaspora-interaction", "interaction"],
664                         "parent-guid" => ["parent-item-uri", "guid"],
665                         "parent-network" => ["post-thread", "network"],
666                         "parent-author-id" => ["post-thread", "author-id"],
667                         "parent-author-link" => ["author", "url"],
668                         "parent-author-name" => ["author", "name"],
669                         "parent-author-nick" => ["author", "nick"],
670                         "parent-author-network" => ["author", "network"],
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 `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
686                         LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`"
687         ],
688         "category-view" => [
689                 "fields" => [
690                         "uri-id" => ["post-category", "uri-id"],
691                         "uid" => ["post-category", "uid"],
692                         "type" => ["post-category", "type"],
693                         "tid" => ["post-category", "tid"],
694                         "name" => ["tag", "name"],
695                         "url" => ["tag", "url"],
696                 ],
697                 "query" => "FROM `post-category`
698                         LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
699         ],
700         "collection-view" => [
701                 "fields" => [
702                         "uri-id" => ["post-collection", "uri-id"],
703                         "type" => ["post-collection", "type"],
704                         "cid" => ["post-collection", "author-id"],
705                         "received" => ["post", "received"],
706                         "created" => ["post", "created"],
707                         "commented" => ["post-thread", "commented"],
708                         "private" => ["post", "private"],
709                         "visible" => ["post", "visible"],
710                         "deleted" => ["post", "deleted"],
711                         "thr-parent-id" => ["post", "thr-parent-id"],
712                         "author-id" => ["post-collection", "author-id"],
713                         "gravity" => ["post", "gravity"],
714                 ],
715                 "query" => "FROM `post-collection`
716                         INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
717                         INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`"
718         ],
719         "media-view" => [
720                 "fields" => [
721                         "uri-id" => ["post-media", "uri-id"],
722                         "type" => ["post-media", "type"],
723                         "received" => ["post", "received"],
724                         "created" => ["post", "created"],
725                         "private" => ["post", "private"],
726                         "visible" => ["post", "visible"],
727                         "deleted" => ["post", "deleted"],
728                         "thr-parent-id" => ["post", "thr-parent-id"],
729                         "author-id" => ["post", "author-id"],
730                         "gravity" => ["post", "gravity"],
731                 ],
732                 "query" => "FROM `post-media`
733                         INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`"
734         ],
735         "tag-view" => [
736                 "fields" => [
737                         "uri-id" => ["post-tag", "uri-id"],
738                         "type" => ["post-tag", "type"],
739                         "tid" => ["post-tag", "tid"],
740                         "cid" => ["post-tag", "cid"],
741                         "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
742                         "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
743                         "tag-type" => "CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END",
744                 ],
745                 "query" => "FROM `post-tag`
746                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
747                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
748         ],
749         "network-item-view" => [
750                 "fields" => [
751                         "uri-id" => ["post-user", "uri-id"],
752                         "parent" => ["post-thread-user", "post-user-id"],
753                         "received" => ["post-user", "received"],
754                         "commented" => ["post-thread-user", "commented"],
755                         "created" => ["post-user", "created"],
756                         "uid" => ["post-user", "uid"],
757                         "starred" => ["post-thread-user", "starred"],
758                         "mention" => ["post-thread-user", "mention"],
759                         "network" => ["post-user", "network"],
760                         "unseen" => ["post-user", "unseen"],
761                         "gravity" => ["post-user", "gravity"],
762                         "contact-id" => ["post-user", "contact-id"],
763                         "contact-type" => ["ownercontact", "contact-type"],
764                 ],
765                 "query" => "FROM `post-user`
766                         INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`                     
767                         INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
768                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
769                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
770                         INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
771                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
772                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
773                         AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
774                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
775                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
776         ],
777         "network-thread-view" => [
778                 "fields" => [
779                         "uri-id" => ["post-thread-user", "uri-id"],
780                         "parent" => ["post-thread-user", "post-user-id"],
781                         "received" => ["post-thread-user", "received"],
782                         "commented" => ["post-thread-user", "commented"],
783                         "created" => ["post-thread-user", "created"],
784                         "uid" => ["post-thread-user", "uid"],
785                         "starred" => ["post-thread-user", "starred"],
786                         "mention" => ["post-thread-user", "mention"],
787                         "network" => ["post-thread-user", "network"],
788                         "contact-id" => ["post-thread-user", "contact-id"],
789                         "contact-type" => ["ownercontact", "contact-type"],
790                 ],
791                 "query" => "FROM `post-thread-user`
792                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
793                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
794                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
795                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
796                         LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
797                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
798                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
799                         AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
800                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
801                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
802         ],
803         "owner-view" => [
804                 "fields" => [
805                         "id" => ["contact", "id"],
806                         "uid" => ["contact", "uid"],
807                         "created" => ["contact", "created"],
808                         "updated" => ["contact", "updated"],
809                         "self" => ["contact", "self"],
810                         "remote_self" => ["contact", "remote_self"],
811                         "rel" => ["contact", "rel"],
812                         "network" => ["contact", "network"],
813                         "protocol" => ["contact", "protocol"],
814                         "name" => ["contact", "name"],
815                         "nick" => ["contact", "nick"],
816                         "location" => ["contact", "location"],
817                         "about" => ["contact", "about"],
818                         "keywords" => ["contact", "keywords"],
819                         "xmpp" => ["contact", "xmpp"],
820                         "matrix" => ["contact", "matrix"],
821                         "attag" => ["contact", "attag"],
822                         "avatar" => ["contact", "avatar"],
823                         "photo" => ["contact", "photo"],
824                         "thumb" => ["contact", "thumb"],
825                         "micro" => ["contact", "micro"],
826                         "header" => ["contact", "header"],
827                         "url" => ["contact", "url"],
828                         "nurl" => ["contact", "nurl"],
829                         "uri-id" => ["contact", "uri-id"],
830                         "addr" => ["contact", "addr"],
831                         "alias" => ["contact", "alias"],
832                         "pubkey" => ["contact", "pubkey"],
833                         "prvkey" => ["contact", "prvkey"],
834                         "batch" => ["contact", "batch"],
835                         "request" => ["contact", "request"],
836                         "notify" => ["contact", "notify"],
837                         "poll" => ["contact", "poll"],
838                         "confirm" => ["contact", "confirm"],
839                         "poco" => ["contact", "poco"],
840                         "subhub" => ["contact", "subhub"],
841                         "hub-verify" => ["contact", "hub-verify"],
842                         "last-update" => ["contact", "last-update"],
843                         "success_update" => ["contact", "success_update"],
844                         "failure_update" => ["contact", "failure_update"],
845                         "name-date" => ["contact", "name-date"],
846                         "uri-date" => ["contact", "uri-date"],
847                         "avatar-date" => ["contact", "avatar-date"],
848                         "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
849                         "term-date" => ["contact", "term-date"],
850                         "last-item" => ["contact", "last-item"],
851                         "priority" => ["contact", "priority"],
852                         "blocked" => ["user", "blocked"],
853                         "block_reason" => ["contact", "block_reason"],
854                         "readonly" => ["contact", "readonly"],
855                         "writable" => ["contact", "writable"],
856                         "forum" => ["contact", "forum"],
857                         "prv" => ["contact", "prv"],
858                         "contact-type" => ["contact", "contact-type"],
859                         "manually-approve" => ["contact", "manually-approve"],
860                         "hidden" => ["contact", "hidden"],
861                         "archive" => ["contact", "archive"],
862                         "pending" => ["contact", "pending"],
863                         "deleted" => ["contact", "deleted"],
864                         "unsearchable" => ["contact", "unsearchable"],
865                         "sensitive" => ["contact", "sensitive"],
866                         "baseurl" => ["contact", "baseurl"],
867                         "reason" => ["contact", "reason"],
868                         "info" => ["contact", "info"],
869                         "bdyear" => ["contact", "bdyear"],
870                         "bd" => ["contact", "bd"],
871                         "notify_new_posts" => ["contact", "notify_new_posts"],
872                         "fetch_further_information" => ["contact", "fetch_further_information"],
873                         "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
874                         "parent-uid" => ["user", "parent-uid"],
875                         "guid" => ["user", "guid"],
876                         "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
877                         "email" => ["user", "email"],
878                         "openid" => ["user", "openid"],
879                         "timezone" => ["user", "timezone"],
880                         "language" => ["user", "language"],
881                         "register_date" => ["user", "register_date"],
882                         "login_date" => ["user", "login_date"],
883                         "last-activity" => ["user", "last-activity"],
884                         "default-location" => ["user", "default-location"],
885                         "allow_location" => ["user", "allow_location"],
886                         "theme" => ["user", "theme"],
887                         "upubkey" => ["user", "pubkey"],
888                         "uprvkey" => ["user", "prvkey"],
889                         "sprvkey" => ["user", "sprvkey"],
890                         "spubkey" => ["user", "spubkey"],
891                         "verified" => ["user", "verified"],
892                         "blockwall" => ["user", "blockwall"],
893                         "hidewall" => ["user", "hidewall"],
894                         "blocktags" => ["user", "blocktags"],
895                         "unkmail" => ["user", "unkmail"],
896                         "cntunkmail" => ["user", "cntunkmail"],
897                         "notify-flags" => ["user", "notify-flags"],
898                         "page-flags" => ["user", "page-flags"],
899                         "account-type" => ["user", "account-type"],
900                         "prvnets" => ["user", "prvnets"],
901                         "maxreq" => ["user", "maxreq"],
902                         "expire" => ["user", "expire"],
903                         "account_removed" => ["user", "account_removed"],
904                         "account_expired" => ["user", "account_expired"],
905                         "account_expires_on" => ["user", "account_expires_on"],
906                         "expire_notification_sent" => ["user", "expire_notification_sent"],
907                         "def_gid" => ["user", "def_gid"],
908                         "allow_cid" => ["user", "allow_cid"],
909                         "allow_gid" => ["user", "allow_gid"],
910                         "deny_cid" => ["user", "deny_cid"],
911                         "deny_gid" => ["user", "deny_gid"],
912                         "openidserver" => ["user", "openidserver"],
913                         "publish" => ["profile", "publish"],
914                         "net-publish" => ["profile", "net-publish"],
915                         "hide-friends" => ["profile", "hide-friends"],
916                         "prv_keywords" => ["profile", "prv_keywords"],
917                         "pub_keywords" => ["profile", "pub_keywords"],
918                         "address" => ["profile", "address"],
919                         "locality" => ["profile", "locality"],
920                         "region" => ["profile", "region"],
921                         "postal-code" => ["profile", "postal-code"],
922                         "country-name" => ["profile", "country-name"],
923                         "homepage" => ["profile", "homepage"],
924                         "homepage_verified" => ["profile", "homepage_verified"],
925                         "dob" => ["profile", "dob"],
926                 ],
927                 "query" => "FROM `user`
928                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
929                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
930         ],
931         "account-view" => [
932                 "fields" => [
933                         "id" => ["contact", "id"],
934                         "url" => ["contact", "url"],
935                         "nurl" => ["contact", "nurl"],
936                         "uri-id" => ["contact", "uri-id"],
937                         "guid" => ["item-uri", "guid"],
938                         "addr" => ["contact", "addr"],
939                         "alias" => ["contact", "alias"],
940                         "name" => ["contact", "name"],
941                         "nick" => ["contact", "nick"],
942                         "about" => ["contact", "about"],
943                         "keywords" => ["contact", "keywords"],
944                         "xmpp" => ["contact", "xmpp"],
945                         "matrix" => ["contact", "matrix"],
946                         "avatar" => ["contact", "avatar"],
947                         "photo" => ["contact", "photo"],
948                         "thumb" => ["contact", "thumb"],
949                         "micro" => ["contact", "micro"],
950                         "header" => ["contact", "header"],
951                         "created" => ["contact", "created"],
952                         "updated" => ["contact", "updated"],
953                         "network" => ["contact", "network"],
954                         "protocol" => ["contact", "protocol"],
955                         "location" => ["contact", "location"],
956                         "attag" => ["contact", "attag"],
957                         "pubkey" => ["contact", "pubkey"],
958                         "prvkey" => ["contact", "prvkey"],
959                         "subscribe" => ["contact", "subscribe"],
960                         "last-update" => ["contact", "last-update"],
961                         "success_update" => ["contact", "success_update"],
962                         "failure_update" => ["contact", "failure_update"],
963                         "failed" => ["contact", "failed"],
964                         "last-item" => ["contact", "last-item"],
965                         "last-discovery" => ["contact", "last-discovery"],
966                         "contact-type" => ["contact", "contact-type"],
967                         "manually-approve" => ["contact", "manually-approve"],
968                         "unsearchable" => ["contact", "unsearchable"],
969                         "sensitive" => ["contact", "sensitive"],
970                         "baseurl" => ["contact", "baseurl"],
971                         "gsid" => ["contact", "gsid"],
972                         "info" => ["contact", "info"],
973                         "bdyear" => ["contact", "bdyear"],
974                         "bd" => ["contact", "bd"],
975                         "poco" => ["contact", "poco"],
976                         "name-date" => ["contact", "name-date"],
977                         "uri-date" => ["contact", "uri-date"],
978                         "avatar-date" => ["contact", "avatar-date"],
979                         "term-date" => ["contact", "term-date"],
980                         "global-ignored" => ["contact", "hidden"],
981                         "global-blocked" => ["contact", "blocked"],
982                         "hidden" => ["contact", "hidden"],
983                         "archive" => ["contact", "archive"],
984                         "deleted" => ["contact", "deleted"],
985                         "blocked" => ["contact", "blocked"],
986                         "dfrn-notify" => ["contact", "notify"],
987                         "dfrn-poll" => ["contact", "poll"],
988                         "diaspora-guid" => ["item-uri", "guid"],
989                         "diaspora-batch" => ["diaspora-contact", "batch"],
990                         "diaspora-notify" => ["diaspora-contact", "notify"],
991                         "diaspora-poll" => ["diaspora-contact", "poll"],
992                         "diaspora-alias" => ["diaspora-contact", "alias"],
993                         "ap-uuid" => ["apcontact", "uuid"],
994                         "ap-type" => ["apcontact", "type"],
995                         "ap-following" => ["apcontact", "following"],
996                         "ap-followers" => ["apcontact", "followers"],
997                         "ap-inbox" => ["apcontact", "inbox"],
998                         "ap-outbox" => ["apcontact", "outbox"],
999                         "ap-sharedinbox" => ["apcontact", "sharedinbox"],
1000                         "ap-generator" => ["apcontact", "generator"],
1001                         "ap-following_count" => ["apcontact", "following_count"],
1002                         "ap-followers_count" => ["apcontact", "followers_count"],
1003                         "ap-statuses_count" => ["apcontact", "statuses_count"],
1004                         "site_name" => ["gserver", "site_name"],
1005                         "platform" => ["gserver", "platform"],
1006                         "version" => ["gserver", "version"],
1007                         "server-blocked" => ["gserver", "blocked"],
1008                         "server-failed" => ["gserver", "failed"],
1009                 ],
1010                 "query" => "FROM `contact`
1011                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
1012                         LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
1013                         LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
1014                         LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
1015                         WHERE `contact`.`uid` = 0"
1016         ],
1017         "account-user-view" => [
1018                 "fields" => [
1019                         "id" => ["ucontact", "id"],
1020                         "pid" => ["contact", "id"],
1021                         "uid" => ["ucontact", "uid"],
1022                         "url" => ["contact", "url"],
1023                         "nurl" => ["contact", "nurl"],
1024                         "uri-id" => ["contact", "uri-id"],
1025                         "guid" => ["item-uri", "guid"],
1026                         "addr" => ["contact", "addr"],
1027                         "alias" => ["contact", "alias"],
1028                         "name" => ["contact", "name"],
1029                         "nick" => ["contact", "nick"],
1030                         "about" => ["contact", "about"],
1031                         "keywords" => ["contact", "keywords"],
1032                         "xmpp" => ["contact", "xmpp"],
1033                         "matrix" => ["contact", "matrix"],
1034                         "avatar" => ["contact", "avatar"],
1035                         "photo" => ["contact", "photo"],
1036                         "thumb" => ["contact", "thumb"],
1037                         "micro" => ["contact", "micro"],
1038                         "header" => ["contact", "header"],
1039                         "created" => ["contact", "created"],
1040                         "updated" => ["contact", "updated"],
1041                         "self" => ["ucontact", "self"],
1042                         "remote_self" => ["ucontact", "remote_self"],
1043                         "rel" =>  ["ucontact", "rel"],
1044                         "network" => ["contact", "network"],
1045                         "protocol" => ["ucontact", "protocol"],
1046                         "location" => ["contact", "location"],
1047                         "attag" => ["ucontact", "attag"],
1048                         "pubkey" => ["contact", "pubkey"],
1049                         "prvkey" => ["contact", "prvkey"],
1050                         "subscribe" => ["contact", "subscribe"],
1051                         "last-update" => ["contact", "last-update"],
1052                         "success_update" => ["contact", "success_update"],
1053                         "failure_update" => ["contact", "failure_update"],
1054                         "failed" => ["contact", "failed"],
1055                         "last-item" => ["contact", "last-item"],
1056                         "last-discovery" => ["contact", "last-discovery"],
1057                         "contact-type" => ["contact", "contact-type"],
1058                         "manually-approve" => ["contact", "manually-approve"],
1059                         "unsearchable" => ["contact", "unsearchable"],
1060                         "sensitive" => ["contact", "sensitive"],
1061                         "baseurl" => ["contact", "baseurl"],
1062                         "gsid" => ["contact", "gsid"],
1063                         "info" => ["ucontact", "info"],
1064                         "bdyear" => ["contact", "bdyear"],
1065                         "bd" => ["contact", "bd"],
1066                         "poco" => ["contact", "poco"],
1067                         "name-date" => ["contact", "name-date"],
1068                         "uri-date" => ["contact", "uri-date"],
1069                         "avatar-date" => ["contact", "avatar-date"],
1070                         "term-date" => ["contact", "term-date"],
1071                         "global-ignored" => ["contact", "hidden"],
1072                         "global-blocked" => ["contact", "blocked"],
1073                         "hidden" => ["ucontact", "hidden"],
1074                         "archive" => ["ucontact", "archive"],
1075                         "pending" => ["ucontact", "pending"],
1076                         "deleted" => ["ucontact", "deleted"],
1077                         "notify_new_posts" => ["ucontact", "notify_new_posts"],
1078                         "fetch_further_information" => ["ucontact", "fetch_further_information"],
1079                         "ffi_keyword_denylist" => ["ucontact", "ffi_keyword_denylist"],
1080                         "rating" => ["ucontact", "rating"],
1081                         "readonly" => ["ucontact", "readonly"],
1082                         "blocked" => ["ucontact", "blocked"],
1083                         "block_reason" => ["ucontact", "block_reason"],
1084                         "subhub" => ["ucontact", "subhub"],
1085                         "hub-verify" => ["ucontact", "hub-verify"],
1086                         "reason" => ["ucontact", "reason"],
1087                         "dfrn-notify" => ["contact", "notify"],
1088                         "dfrn-poll" => ["contact", "poll"],
1089                         "diaspora-guid" => ["item-uri", "guid"],
1090                         "diaspora-batch" => ["diaspora-contact", "batch"],
1091                         "diaspora-notify" => ["diaspora-contact", "notify"],
1092                         "diaspora-poll" => ["diaspora-contact", "poll"],
1093                         "diaspora-alias" => ["diaspora-contact", "alias"],
1094                         "diaspora-interacting_count" => ["diaspora-contact", "interacting_count"],
1095                         "diaspora-interacted_count" => ["diaspora-contact", "interacted_count"],
1096                         "diaspora-post_count" => ["diaspora-contact", "post_count"],
1097                         "ap-uuid" => ["apcontact", "uuid"],
1098                         "ap-type" => ["apcontact", "type"],
1099                         "ap-following" => ["apcontact", "following"],
1100                         "ap-followers" => ["apcontact", "followers"],
1101                         "ap-inbox" => ["apcontact", "inbox"],
1102                         "ap-outbox" => ["apcontact", "outbox"],
1103                         "ap-sharedinbox" => ["apcontact", "sharedinbox"],
1104                         "ap-generator" => ["apcontact", "generator"],
1105                         "ap-following_count" => ["apcontact", "following_count"],
1106                         "ap-followers_count" => ["apcontact", "followers_count"],
1107                         "ap-statuses_count" => ["apcontact", "statuses_count"],
1108                         "site_name" => ["gserver", "site_name"],
1109                         "platform" => ["gserver", "platform"],
1110                         "version" => ["gserver", "version"],
1111                         "server-blocked" => ["gserver", "blocked"],
1112                         "server-failed" => ["gserver", "failed"],
1113                 ],
1114                 "query" => "FROM `contact` AS `ucontact`
1115                         INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
1116                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
1117                         LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
1118                         LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
1119                         LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`"
1120         ],
1121         "pending-view" => [
1122                 "fields" => [
1123                         "id" => ["register", "id"],
1124                         "hash" => ["register", "hash"],
1125                         "created" => ["register", "created"],
1126                         "uid" => ["register", "uid"],
1127                         "password" => ["register", "password"],
1128                         "language" => ["register", "language"],
1129                         "note" => ["register", "note"],
1130                         "self" => ["contact", "self"],
1131                         "name" => ["contact", "name"],
1132                         "url" => ["contact", "url"],
1133                         "micro" => ["contact", "micro"],
1134                         "email" => ["user", "email"],
1135                         "nick" => ["contact", "nick"],
1136                 ],
1137                 "query" => "FROM `register`
1138                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1139                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
1140         ],
1141         "tag-search-view" => [
1142                 "fields" => [
1143                         "uri-id" => ["post-tag", "uri-id"],
1144                         "uid" => ["post-user", "uid"],
1145                         "iid" => ["post-user", "id"],
1146                         "private" => ["post-user", "private"],
1147                         "wall" => ["post-user", "wall"],
1148                         "origin" => ["post-user", "origin"],
1149                         "global" => ["post-user", "global"],
1150                         "gravity" => ["post-user", "gravity"],
1151                         "received" => ["post-user", "received"],
1152                         "network" => ["post-user", "network"],
1153                         "author-id" => ["post-user", "author-id"],
1154                         "name" => ["tag", "name"],
1155                 ],
1156                 "query" => "FROM `post-tag`
1157                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1158                         STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
1159                         WHERE `post-tag`.`type` = 1"
1160         ],
1161         "workerqueue-view" => [
1162                 "fields" => [
1163                         "pid" => ["process", "pid"],
1164                         "priority" => ["workerqueue", "priority"],
1165                 ],
1166                 "query" => "FROM `process`
1167                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1168                         WHERE NOT `workerqueue`.`done`"
1169         ],
1170         "profile_field-view" => [
1171                 "fields" => [
1172                         "id" => ["profile_field", "id"],
1173                         "uid" => ["profile_field", "uid"],
1174                         "label" => ["profile_field", "label"],
1175                         "value" => ["profile_field", "value"],
1176                         "order" => ["profile_field", "order"],
1177                         "psid"=> ["profile_field", "psid"],
1178                         "allow_cid" => ["permissionset", "allow_cid"],
1179                         "allow_gid" => ["permissionset", "allow_gid"],
1180                         "deny_cid" => ["permissionset", "deny_cid"],
1181                         "deny_gid" => ["permissionset", "deny_gid"],
1182                         "created" => ["profile_field", "created"],
1183                         "edited" => ["profile_field", "edited"],
1184                 ],
1185                 "query" => "FROM `profile_field`
1186                         INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`"
1187         ],
1188         "diaspora-contact-view" => [
1189                 "fields" => [
1190                         "uri-id" => ["diaspora-contact", "uri-id"],
1191                         "url" => ["item-uri", "uri"],
1192                         "guid" => ["item-uri", "guid"],
1193                         "addr" => ["diaspora-contact", "addr"],
1194                         "alias" => ["diaspora-contact", "alias"],
1195                         "nick" => ["diaspora-contact", "nick"],
1196                         "name" => ["diaspora-contact", "name"],
1197                         "given-name" => ["diaspora-contact", "given-name"],
1198                         "family-name" => ["diaspora-contact", "family-name"],
1199                         "photo" => ["diaspora-contact", "photo"],
1200                         "photo-medium" => ["diaspora-contact", "photo-medium"],
1201                         "photo-small" => ["diaspora-contact", "photo-small"],
1202                         "batch" => ["diaspora-contact", "batch"],
1203                         "notify" => ["diaspora-contact", "notify"],
1204                         "poll" => ["diaspora-contact", "poll"],
1205                         "subscribe" => ["diaspora-contact", "subscribe"],
1206                         "searchable" => ["diaspora-contact", "searchable"],
1207                         "pubkey" => ["diaspora-contact", "pubkey"],
1208                         "baseurl" => ["gserver", "url"],
1209                         "gsid" => ["diaspora-contact", "gsid"],
1210                         "created" => ["diaspora-contact", "created"],
1211                         "updated" => ["diaspora-contact", "updated"],
1212                         "interacting_count" => ["diaspora-contact", "interacting_count"],
1213                         "interacted_count" => ["diaspora-contact", "interacted_count"],
1214                         "post_count" => ["diaspora-contact", "post_count"],
1215                 ],
1216                 "query" => "FROM `diaspora-contact`
1217                         INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
1218                         LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`"
1219         ],
1220 ];