]> git.mxchange.org Git - friendica.git/blob - static/dbview.config.php
Merge pull request #11588 from annando/mergecontact
[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                         "private" => ["post", "private"],
681                         "visible" => ["post", "visible"],
682                         "deleted" => ["post", "deleted"],
683                         "thr-parent-id" => ["post", "thr-parent-id"],
684                         "author-id" => ["post", "author-id"],
685                         "gravity" => ["post", "gravity"],
686                 ],
687                 "query" => "FROM `post-collection`
688                         INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
689                         INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`"
690         ],
691         "tag-view" => [
692                 "fields" => [
693                         "uri-id" => ["post-tag", "uri-id"],
694                         "type" => ["post-tag", "type"],
695                         "tid" => ["post-tag", "tid"],
696                         "cid" => ["post-tag", "cid"],
697                         "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
698                         "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
699                         "tag-type" => "CASE `cid` WHEN 0 THEN `tag`.`type` ELSE 1 END",
700                 ],
701                 "query" => "FROM `post-tag`
702                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
703                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
704         ],
705         "network-item-view" => [
706                 "fields" => [
707                         "uri-id" => ["post-user", "uri-id"],
708                         "parent" => ["parent-post", "id"],
709                         "received" => ["post-user", "received"],
710                         "commented" => ["post-thread-user", "commented"],
711                         "created" => ["post-user", "created"],
712                         "uid" => ["post-user", "uid"],
713                         "starred" => ["post-thread-user", "starred"],
714                         "mention" => ["post-thread-user", "mention"],
715                         "network" => ["post-user", "network"],
716                         "unseen" => ["post-user", "unseen"],
717                         "gravity" => ["post-user", "gravity"],
718                         "contact-id" => ["post-user", "contact-id"],
719                         "contact-type" => ["ownercontact", "contact-type"],
720                 ],
721                 "query" => "FROM `post-user`
722                         STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`                  
723                         INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
724                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
725                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
726                         INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
727                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
728                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
729                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
730                         AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
731                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
732                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
733         ],
734         "network-thread-view" => [
735                 "fields" => [
736                         "uri-id" => ["post-thread-user", "uri-id"],
737                         "parent" => ["parent-post", "id"],
738                         "received" => ["post-thread-user", "received"],
739                         "commented" => ["post-thread-user", "commented"],
740                         "created" => ["post-thread-user", "created"],
741                         "uid" => ["post-thread-user", "uid"],
742                         "starred" => ["post-thread-user", "starred"],
743                         "mention" => ["post-thread-user", "mention"],
744                         "network" => ["post-thread-user", "network"],
745                         "contact-id" => ["post-thread-user", "contact-id"],
746                         "contact-type" => ["ownercontact", "contact-type"],
747                 ],
748                 "query" => "FROM `post-thread-user`
749                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
750                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
751                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
752                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
753                         LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
754                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
755                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
756                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
757                         AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
758                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
759                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
760         ],
761         "owner-view" => [
762                 "fields" => [
763                         "id" => ["contact", "id"],
764                         "uid" => ["contact", "uid"],
765                         "created" => ["contact", "created"],
766                         "updated" => ["contact", "updated"],
767                         "self" => ["contact", "self"],
768                         "remote_self" => ["contact", "remote_self"],
769                         "rel" => ["contact", "rel"],
770                         "network" => ["contact", "network"],
771                         "protocol" => ["contact", "protocol"],
772                         "name" => ["contact", "name"],
773                         "nick" => ["contact", "nick"],
774                         "location" => ["contact", "location"],
775                         "about" => ["contact", "about"],
776                         "keywords" => ["contact", "keywords"],
777                         "xmpp" => ["contact", "xmpp"],
778                         "matrix" => ["contact", "matrix"],
779                         "attag" => ["contact", "attag"],
780                         "avatar" => ["contact", "avatar"],
781                         "photo" => ["contact", "photo"],
782                         "thumb" => ["contact", "thumb"],
783                         "micro" => ["contact", "micro"],
784                         "header" => ["contact", "header"],
785                         "url" => ["contact", "url"],
786                         "nurl" => ["contact", "nurl"],
787                         "uri-id" => ["contact", "uri-id"],
788                         "addr" => ["contact", "addr"],
789                         "alias" => ["contact", "alias"],
790                         "pubkey" => ["contact", "pubkey"],
791                         "prvkey" => ["contact", "prvkey"],
792                         "batch" => ["contact", "batch"],
793                         "request" => ["contact", "request"],
794                         "notify" => ["contact", "notify"],
795                         "poll" => ["contact", "poll"],
796                         "confirm" => ["contact", "confirm"],
797                         "poco" => ["contact", "poco"],
798                         "subhub" => ["contact", "subhub"],
799                         "hub-verify" => ["contact", "hub-verify"],
800                         "last-update" => ["contact", "last-update"],
801                         "success_update" => ["contact", "success_update"],
802                         "failure_update" => ["contact", "failure_update"],
803                         "name-date" => ["contact", "name-date"],
804                         "uri-date" => ["contact", "uri-date"],
805                         "avatar-date" => ["contact", "avatar-date"],
806                         "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
807                         "term-date" => ["contact", "term-date"],
808                         "last-item" => ["contact", "last-item"],
809                         "priority" => ["contact", "priority"],
810                         "blocked" => ["user", "blocked"],
811                         "block_reason" => ["contact", "block_reason"],
812                         "readonly" => ["contact", "readonly"],
813                         "writable" => ["contact", "writable"],
814                         "forum" => ["contact", "forum"],
815                         "prv" => ["contact", "prv"],
816                         "contact-type" => ["contact", "contact-type"],
817                         "manually-approve" => ["contact", "manually-approve"],
818                         "hidden" => ["contact", "hidden"],
819                         "archive" => ["contact", "archive"],
820                         "pending" => ["contact", "pending"],
821                         "deleted" => ["contact", "deleted"],
822                         "unsearchable" => ["contact", "unsearchable"],
823                         "sensitive" => ["contact", "sensitive"],
824                         "baseurl" => ["contact", "baseurl"],
825                         "reason" => ["contact", "reason"],
826                         "info" => ["contact", "info"],
827                         "bdyear" => ["contact", "bdyear"],
828                         "bd" => ["contact", "bd"],
829                         "notify_new_posts" => ["contact", "notify_new_posts"],
830                         "fetch_further_information" => ["contact", "fetch_further_information"],
831                         "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
832                         "parent-uid" => ["user", "parent-uid"],
833                         "guid" => ["user", "guid"],
834                         "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
835                         "email" => ["user", "email"],
836                         "openid" => ["user", "openid"],
837                         "timezone" => ["user", "timezone"],
838                         "language" => ["user", "language"],
839                         "register_date" => ["user", "register_date"],
840                         "login_date" => ["user", "login_date"],
841                         "default-location" => ["user", "default-location"],
842                         "allow_location" => ["user", "allow_location"],
843                         "theme" => ["user", "theme"],
844                         "upubkey" => ["user", "pubkey"],
845                         "uprvkey" => ["user", "prvkey"],
846                         "sprvkey" => ["user", "sprvkey"],
847                         "spubkey" => ["user", "spubkey"],
848                         "verified" => ["user", "verified"],
849                         "blockwall" => ["user", "blockwall"],
850                         "hidewall" => ["user", "hidewall"],
851                         "blocktags" => ["user", "blocktags"],
852                         "unkmail" => ["user", "unkmail"],
853                         "cntunkmail" => ["user", "cntunkmail"],
854                         "notify-flags" => ["user", "notify-flags"],
855                         "page-flags" => ["user", "page-flags"],
856                         "account-type" => ["user", "account-type"],
857                         "prvnets" => ["user", "prvnets"],
858                         "maxreq" => ["user", "maxreq"],
859                         "expire" => ["user", "expire"],
860                         "account_removed" => ["user", "account_removed"],
861                         "account_expired" => ["user", "account_expired"],
862                         "account_expires_on" => ["user", "account_expires_on"],
863                         "expire_notification_sent" => ["user", "expire_notification_sent"],
864                         "def_gid" => ["user", "def_gid"],
865                         "allow_cid" => ["user", "allow_cid"],
866                         "allow_gid" => ["user", "allow_gid"],
867                         "deny_cid" => ["user", "deny_cid"],
868                         "deny_gid" => ["user", "deny_gid"],
869                         "openidserver" => ["user", "openidserver"],
870                         "publish" => ["profile", "publish"],
871                         "net-publish" => ["profile", "net-publish"],
872                         "hide-friends" => ["profile", "hide-friends"],
873                         "prv_keywords" => ["profile", "prv_keywords"],
874                         "pub_keywords" => ["profile", "pub_keywords"],
875                         "address" => ["profile", "address"],
876                         "locality" => ["profile", "locality"],
877                         "region" => ["profile", "region"],
878                         "postal-code" => ["profile", "postal-code"],
879                         "country-name" => ["profile", "country-name"],
880                         "homepage" => ["profile", "homepage"],
881                         "dob" => ["profile", "dob"],
882                 ],
883                 "query" => "FROM `user`
884                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
885                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
886         ],
887         "account-view" => [
888                 "fields" => [
889                         "id" => ["contact", "id"],
890                         "url" => ["contact", "url"],
891                         "nurl" => ["contact", "nurl"],
892                         "uri-id" => ["contact", "uri-id"],
893                         "guid" => ["item-uri", "guid"],
894                         "addr" => ["contact", "addr"],
895                         "alias" => ["contact", "alias"],
896                         "name" => ["contact", "name"],
897                         "nick" => ["contact", "nick"],
898                         "about" => ["contact", "about"],
899                         "keywords" => ["contact", "keywords"],
900                         "xmpp" => ["contact", "xmpp"],
901                         "matrix" => ["contact", "matrix"],
902                         "avatar" => ["contact", "avatar"],
903                         "photo" => ["contact", "photo"],
904                         "thumb" => ["contact", "thumb"],
905                         "micro" => ["contact", "micro"],
906                         "header" => ["contact", "header"],
907                         "created" => ["contact", "created"],
908                         "updated" => ["contact", "updated"],
909                         "network" => ["contact", "network"],
910                         "protocol" => ["contact", "protocol"],
911                         "location" => ["contact", "location"],
912                         "attag" => ["contact", "attag"],
913                         "pubkey" => ["contact", "pubkey"],
914                         "prvkey" => ["contact", "prvkey"],
915                         "subscribe" => ["contact", "subscribe"],
916                         "last-update" => ["contact", "last-update"],
917                         "success_update" => ["contact", "success_update"],
918                         "failure_update" => ["contact", "failure_update"],
919                         "failed" => ["contact", "failed"],
920                         "last-item" => ["contact", "last-item"],
921                         "last-discovery" => ["contact", "last-discovery"],
922                         "contact-type" => ["contact", "contact-type"],
923                         "manually-approve" => ["contact", "manually-approve"],
924                         "unsearchable" => ["contact", "unsearchable"],
925                         "sensitive" => ["contact", "sensitive"],
926                         "baseurl" => ["contact", "baseurl"],
927                         "gsid" => ["contact", "gsid"],
928                         "info" => ["contact", "info"],
929                         "bdyear" => ["contact", "bdyear"],
930                         "bd" => ["contact", "bd"],
931                         "poco" => ["contact", "poco"],
932                         "name-date" => ["contact", "name-date"],
933                         "uri-date" => ["contact", "uri-date"],
934                         "avatar-date" => ["contact", "avatar-date"],
935                         "term-date" => ["contact", "term-date"],
936                         "global-ignored" => ["contact", "hidden"],
937                         "global-blocked" => ["contact", "blocked"],
938                         "hidden" => ["contact", "hidden"],
939                         "archive" => ["contact", "archive"],
940                         "deleted" => ["contact", "deleted"],
941                         "blocked" => ["contact", "blocked"],
942                         "dfrn-notify" => ["contact", "notify"],
943                         "dfrn-poll" => ["contact", "poll"],
944                         "diaspora-guid" => ["fcontact", "guid"],
945                         "diaspora-batch" => ["fcontact", "batch"],
946                         "diaspora-notify" => ["fcontact", "notify"],
947                         "diaspora-poll" => ["fcontact", "poll"],
948                         "diaspora-alias" => ["fcontact", "alias"],
949                         "ap-uuid" => ["apcontact", "uuid"],
950                         "ap-type" => ["apcontact", "type"],
951                         "ap-following" => ["apcontact", "following"],
952                         "ap-followers" => ["apcontact", "followers"],
953                         "ap-inbox" => ["apcontact", "inbox"],
954                         "ap-outbox" => ["apcontact", "outbox"],
955                         "ap-sharedinbox" => ["apcontact", "sharedinbox"],
956                         "ap-generator" => ["apcontact", "generator"],
957                         "ap-following_count" => ["apcontact", "following_count"],
958                         "ap-followers_count" => ["apcontact", "followers_count"],
959                         "ap-statuses_count" => ["apcontact", "statuses_count"],
960                         "site_name" => ["gserver", "site_name"],
961                         "platform" => ["gserver", "platform"],
962                         "version" => ["gserver", "version"],
963                 ],
964                 "query" => "FROM `contact`
965                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
966                         LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
967                         LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
968                         LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
969                         WHERE `contact`.`uid` = 0"                      
970         ],
971         "account-user-view" => [
972                 "fields" => [
973                         "id" => ["ucontact", "id"],
974                         "pid" => ["contact", "id"],
975                         "uid" => ["ucontact", "uid"],
976                         "url" => ["contact", "url"],
977                         "nurl" => ["contact", "nurl"],
978                         "uri-id" => ["contact", "uri-id"],
979                         "guid" => ["item-uri", "guid"],
980                         "addr" => ["contact", "addr"],
981                         "alias" => ["contact", "alias"],
982                         "name" => ["contact", "name"],
983                         "nick" => ["contact", "nick"],
984                         "about" => ["contact", "about"],
985                         "keywords" => ["contact", "keywords"],
986                         "xmpp" => ["contact", "xmpp"],
987                         "matrix" => ["contact", "matrix"],
988                         "avatar" => ["contact", "avatar"],
989                         "photo" => ["contact", "photo"],
990                         "thumb" => ["contact", "thumb"],
991                         "micro" => ["contact", "micro"],
992                         "header" => ["contact", "header"],
993                         "created" => ["contact", "created"],
994                         "updated" => ["contact", "updated"],
995                         "self" => ["ucontact", "self"],
996                         "remote_self" => ["ucontact", "remote_self"],
997                         "rel" =>  ["ucontact", "rel"],
998                         "network" => ["contact", "network"],
999                         "protocol" => ["ucontact", "protocol"],
1000                         "location" => ["contact", "location"],
1001                         "attag" => ["ucontact", "attag"],
1002                         "pubkey" => ["contact", "pubkey"],
1003                         "prvkey" => ["contact", "prvkey"],
1004                         "subscribe" => ["contact", "subscribe"],
1005                         "last-update" => ["contact", "last-update"],
1006                         "success_update" => ["contact", "success_update"],
1007                         "failure_update" => ["contact", "failure_update"],
1008                         "failed" => ["contact", "failed"],
1009                         "last-item" => ["contact", "last-item"],
1010                         "last-discovery" => ["contact", "last-discovery"],
1011                         "contact-type" => ["contact", "contact-type"],
1012                         "manually-approve" => ["contact", "manually-approve"],
1013                         "unsearchable" => ["contact", "unsearchable"],
1014                         "sensitive" => ["contact", "sensitive"],
1015                         "baseurl" => ["contact", "baseurl"],
1016                         "gsid" => ["contact", "gsid"],
1017                         "info" => ["ucontact", "info"],
1018                         "bdyear" => ["contact", "bdyear"],
1019                         "bd" => ["contact", "bd"],
1020                         "poco" => ["contact", "poco"],
1021                         "name-date" => ["contact", "name-date"],
1022                         "uri-date" => ["contact", "uri-date"],
1023                         "avatar-date" => ["contact", "avatar-date"],
1024                         "term-date" => ["contact", "term-date"],
1025                         "global-ignored" => ["contact", "hidden"],
1026                         "global-blocked" => ["contact", "blocked"],
1027                         "hidden" => ["ucontact", "hidden"],
1028                         "archive" => ["ucontact", "archive"],
1029                         "pending" => ["ucontact", "pending"],
1030                         "deleted" => ["ucontact", "deleted"],
1031                         "notify_new_posts" => ["ucontact", "notify_new_posts"],
1032                         "fetch_further_information" => ["ucontact", "fetch_further_information"],
1033                         "ffi_keyword_denylist" => ["ucontact", "ffi_keyword_denylist"],
1034                         "rating" => ["ucontact", "rating"],
1035                         "readonly" => ["ucontact", "readonly"],
1036                         "blocked" => ["ucontact", "blocked"],
1037                         "block_reason" => ["ucontact", "block_reason"],
1038                         "subhub" => ["ucontact", "subhub"],
1039                         "hub-verify" => ["ucontact", "hub-verify"],
1040                         "reason" => ["ucontact", "reason"],
1041                         "dfrn-notify" => ["contact", "notify"],
1042                         "dfrn-poll" => ["contact", "poll"],
1043                         "diaspora-guid" => ["fcontact", "guid"],
1044                         "diaspora-batch" => ["fcontact", "batch"],
1045                         "diaspora-notify" => ["fcontact", "notify"],
1046                         "diaspora-poll" => ["fcontact", "poll"],
1047                         "diaspora-alias" => ["fcontact", "alias"],
1048                         "ap-uuid" => ["apcontact", "uuid"],
1049                         "ap-type" => ["apcontact", "type"],
1050                         "ap-following" => ["apcontact", "following"],
1051                         "ap-followers" => ["apcontact", "followers"],
1052                         "ap-inbox" => ["apcontact", "inbox"],
1053                         "ap-outbox" => ["apcontact", "outbox"],
1054                         "ap-sharedinbox" => ["apcontact", "sharedinbox"],
1055                         "ap-generator" => ["apcontact", "generator"],
1056                         "ap-following_count" => ["apcontact", "following_count"],
1057                         "ap-followers_count" => ["apcontact", "followers_count"],
1058                         "ap-statuses_count" => ["apcontact", "statuses_count"],
1059                         "site_name" => ["gserver", "site_name"],
1060                         "platform" => ["gserver", "platform"],
1061                         "version" => ["gserver", "version"],
1062                 ],
1063                 "query" => "FROM `contact` AS `ucontact`
1064                         INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
1065                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
1066                         LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
1067                         LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'
1068                         LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`"
1069         ],
1070         "pending-view" => [
1071                 "fields" => [
1072                         "id" => ["register", "id"],
1073                         "hash" => ["register", "hash"],
1074                         "created" => ["register", "created"],
1075                         "uid" => ["register", "uid"],
1076                         "password" => ["register", "password"],
1077                         "language" => ["register", "language"],
1078                         "note" => ["register", "note"],
1079                         "self" => ["contact", "self"],
1080                         "name" => ["contact", "name"],
1081                         "url" => ["contact", "url"],
1082                         "micro" => ["contact", "micro"],
1083                         "email" => ["user", "email"],
1084                         "nick" => ["contact", "nick"],
1085                 ],
1086                 "query" => "FROM `register`
1087                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1088                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
1089         ],
1090         "tag-search-view" => [
1091                 "fields" => [
1092                         "uri-id" => ["post-tag", "uri-id"],
1093                         "uid" => ["post-user", "uid"],
1094                         "iid" => ["post-user", "id"],
1095                         "private" => ["post-user", "private"],
1096                         "wall" => ["post-user", "wall"],
1097                         "origin" => ["post-user", "origin"],
1098                         "global" => ["post-user", "global"],
1099                         "gravity" => ["post-user", "gravity"],
1100                         "received" => ["post-user", "received"],
1101                         "network" => ["post-user", "network"],
1102                         "author-id" => ["post-user", "author-id"],
1103                         "name" => ["tag", "name"],
1104                 ],
1105                 "query" => "FROM `post-tag`
1106                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
1107                         STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
1108                         WHERE `post-tag`.`type` = 1"
1109         ],
1110         "workerqueue-view" => [
1111                 "fields" => [
1112                         "pid" => ["process", "pid"],
1113                         "priority" => ["workerqueue", "priority"],
1114                 ],
1115                 "query" => "FROM `process`
1116                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
1117                         WHERE NOT `workerqueue`.`done`"
1118         ],
1119         "profile_field-view" => [
1120                 "fields" => [
1121                         "id" => ["profile_field", "id"],
1122                         "uid" => ["profile_field", "uid"],
1123                         "label" => ["profile_field", "label"],
1124                         "value" => ["profile_field", "value"],
1125                         "order" => ["profile_field", "order"],
1126                         "psid"=> ["profile_field", "psid"],
1127                         "allow_cid" => ["permissionset", "allow_cid"],
1128                         "allow_gid" => ["permissionset", "allow_gid"],
1129                         "deny_cid" => ["permissionset", "deny_cid"],
1130                         "deny_gid" => ["permissionset", "deny_gid"],
1131                         "created" => ["profile_field", "created"],
1132                         "edited" => ["profile_field", "edited"],
1133                 ],
1134                 "query" => "FROM `profile_field`
1135                         INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`"
1136         ],
1137 ];
1138