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