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