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