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