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