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