3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
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.
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.
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/>.
20 * Main view structure configuration file.
22 * Here are described all the view Friendica needs to work.
24 * Syntax (braces indicate optionale values):
27 * "<field name>" => ["table", "field"],
28 * "<field name>" => "SQL expression",
31 * "query" => "FROM `table` INNER JOIN `other-table` ..."
35 * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value in dbstructure.config.php.
42 "id" => ["item", "id"],
43 "item_id" => ["item", "id"],
44 "uid" => ["item", "uid"],
45 "internal-uid" => ["item", "uid"],
46 "parent" => ["item", "parent"],
47 "uri" => ["item", "uri"],
48 "uri-id" => ["item", "uri-id"],
49 "internal-uri-id" => ["item", "uri-id"],
50 "parent-uri" => ["item", "parent-uri"],
51 "parent-uri-id" => ["item", "parent-uri-id"],
52 "thr-parent" => ["item", "thr-parent"],
53 "thr-parent-id" => ["item", "thr-parent-id"],
54 "guid" => ["item", "guid"],
55 "type" => ["item", "type"],
56 "wall" => ["item", "wall"],
57 "gravity" => ["item", "gravity"],
58 "extid" => ["item", "extid"],
59 "created" => ["item", "created"],
60 "edited" => ["item", "edited"],
61 "commented" => ["item", "commented"],
62 "received" => ["item", "received"],
63 "changed" => ["item", "changed"],
64 "resource-id" => ["item", "resource-id"],
65 "post-type" => ["item", "post-type"],
66 "private" => ["item", "private"],
67 "pubmail" => ["item", "pubmail"],
68 "moderated" => ["item", "moderated"],
69 "visible" => ["item", "visible"],
70 "starred" => ["item", "starred"],
71 "bookmark" => ["item", "bookmark"],
72 "unseen" => ["item", "unseen"],
73 "deleted" => ["item", "deleted"],
74 "origin" => ["item", "origin"],
75 "forum_mode" => ["item", "forum_mode"],
76 "mention" => ["item", "mention"],
77 "global" => ["item", "global"],
78 "network" => ["item", "network"],
79 "icid" => ["item", "icid"],
80 "vid" => ["item", "vid"],
81 "psid" => ["item", "psid"],
82 "attach" => ["item", "attach"],
83 "internal-file-count" => "(SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`)",
85 "verb" => "IF (`item`.`vid` IS NULL, '', `verb`.`name`)",
86 "title" => ["item-content", "title"],
87 "content-warning" => ["item-content", "content-warning"],
88 "raw-body" => ["item-content", "raw-body"],
89 "body" => ["item-content", "body"],
90 "rendered-hash" => ["item-content", "rendered-hash"],
91 "rendered-html" => ["item-content", "rendered-html"],
92 "language" => ["item-content", "language"],
93 "plink" => ["item-content", "plink"],
94 "location" => ["item-content", "location"],
95 "coord" => ["item-content", "coord"],
96 "app" => ["item-content", "app"],
97 "object-type" => ["item-content", "object-type"],
98 "object" => ["item-content", "object"],
99 "target-type" => ["item-content", "target-type"],
100 "target" => ["item-content", "target"],
101 "contact-id" => ["item", "contact-id"],
102 "contact-link" => ["contact", "url"],
103 "contact-addr" => ["contact", "addr"],
104 "contact-name" => ["contact", "name"],
105 "contact-nick" => ["contact", "nick"],
106 "contact-avatar" => ["contact", "thumb"],
107 "contact-network" => ["contact", "network"],
108 "contact-blocked" => ["contact", "blocked"],
109 "contact-readonly" => ["contact", "readonly"],
110 "contact-pending" => ["contact", "pending"],
111 "contact-rel" => ["contact", "rel"],
112 "contact-uid" => ["contact", "uid"],
113 "writable" => "IF (`item`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
114 "self" => ["contact", "self"],
115 "cid" => ["contact", "id"],
116 "alias" => ["contact", "alias"],
117 "photo" => ["contact", "photo"],
118 "name-date" => ["contact", "name-date"],
119 "uri-date" => ["contact", "uri-date"],
120 "avatar-date" => ["contact", "avatar-date"],
121 "thumb" => ["contact", "thumb"],
122 "dfrn-id" => ["contact", "dfrn-id"],
123 "author-id" => ["item", "author-id"],
124 "author-link" => ["author", "url"],
125 "author-addr" => ["author", "addr"],
126 "author-name" => "IF (`contact`.`url` = `author`.`url`, `contact`.`name`, `author`.`name`)",
127 "author-nick" => ["author", "nick"],
128 "author-avatar" => "IF (`contact`.`url` = `author`.`url`, `contact`.`thumb`, `author`.`thumb`)",
129 "author-network" => ["author", "network"],
130 "author-blocked" => ["author", "blocked"],
131 "author-hidden" => ["author", "hidden"],
132 "owner-id" => ["item", "owner-id"],
133 "owner-link" => ["owner", "url"],
134 "owner-addr" => ["owner", "addr"],
135 "owner-name" => "IF (`contact`.`url` = `owner`.`url`, `contact`.`name`, `owner`.`name`)",
136 "owner-nick" => ["owner", "nick"],
137 "owner-avatar" => "IF (`contact`.`url` = `owner`.`url`, `contact`.`thumb`, `owner`.`thumb`)",
138 "owner-network" => ["owner", "network"],
139 "owner-blocked" => ["owner", "blocked"],
140 "owner-hidden" => ["owner", "hidden"],
141 "causer-id" => ["item", "causer-id"],
142 "causer-link" => ["causer", "url"],
143 "causer-addr" => ["causer", "addr"],
144 "causer-name" => ["causer", "name"],
145 "causer-nick" => ["causer", "nick"],
146 "causer-avatar" => ["causer", "thumb"],
147 "causer-network" => ["causer", "network"],
148 "causer-blocked" => ["causer", "blocked"],
149 "causer-hidden" => ["causer", "hidden"],
150 "causer-contact-type" => ["causer", "contact-type"],
151 "postopts" => ["post-delivery-data", "postopts"],
152 "inform" => ["post-delivery-data", "inform"],
153 "delivery_queue_count" => ["post-delivery-data", "queue_count"],
154 "delivery_queue_done" => ["post-delivery-data", "queue_done"],
155 "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
156 "allow_cid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
157 "allow_gid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
158 "deny_cid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
159 "deny_gid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
160 "event-id" => ["item", "event-id"],
161 "event-created" => ["event", "created"],
162 "event-edited" => ["event", "edited"],
163 "event-start" => ["event", "start"],
164 "event-finish" => ["event", "finish"],
165 "event-summary" => ["event", "summary"],
166 "event-desc" => ["event", "desc"],
167 "event-location" => ["event", "location"],
168 "event-type" => ["event", "type"],
169 "event-nofinish" => ["event", "nofinish"],
170 "event-adjust" => ["event", "adjust"],
171 "event-ignore" => ["event", "ignore"],
172 "signed_text" => ["diaspora-interaction", "interaction"],
173 "parent-guid" => ["parent-item", "guid"],
174 "parent-network" => ["parent-item", "network"],
175 "parent-author-id" => ["parent-item", "author-id"],
176 "parent-author-link" => ["parent-item-author", "url"],
177 "parent-author-name" => ["parent-item-author", "name"],
178 "parent-author-network" => ["parent-item-author", "network"],
180 "query" => "FROM `item`
181 STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
182 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
183 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
184 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
185 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
186 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
187 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
188 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
189 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
190 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
191 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
192 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`"
196 "uri-id" => ["post-category", "uri-id"],
197 "uid" => ["post-category", "uid"],
198 "uri" => ["item-uri", "uri"],
199 "guid" => ["item-uri", "guid"],
200 "type" => ["post-category", "type"],
201 "tid" => ["post-category", "tid"],
202 "name" => ["tag", "name"],
203 "url" => ["tag", "url"],
205 "query" => "FROM `post-category`
206 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
207 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
211 "uri-id" => ["post-tag", "uri-id"],
212 "uri" => ["item-uri", "uri"],
213 "guid" => ["item-uri", "guid"],
214 "type" => ["post-tag", "type"],
215 "tid" => ["post-tag", "tid"],
216 "cid" => ["post-tag", "cid"],
217 "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
218 "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
220 "query" => "FROM `post-tag`
221 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
222 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
223 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
225 "network-item-view" => [
227 "uri-id" => ["item", "parent-uri-id"],
228 "uri" => ["item", "parent-uri"],
229 "parent" => ["item", "parent"],
230 "received" => ["item", "received"],
231 "commented" => ["item", "commented"],
232 "created" => ["item", "created"],
233 "uid" => ["item", "uid"],
234 "starred" => ["item", "starred"],
235 "mention" => ["item", "mention"],
236 "network" => ["item", "network"],
237 "unseen" => ["item", "unseen"],
238 "gravity" => ["item", "gravity"],
239 "contact-id" => ["item", "contact-id"],
240 "contact-type" => ["ownercontact", "contact-type"],
242 "query" => "FROM `item`
243 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
244 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
245 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
246 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
247 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
248 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
249 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
250 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
251 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
252 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
253 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
255 "network-thread-view" => [
257 "uri-id" => ["item", "uri-id"],
258 "uri" => ["item", "uri"],
259 "parent-uri-id" => ["item", "parent-uri-id"],
260 "parent" => ["thread", "iid"],
261 "received" => ["thread", "received"],
262 "commented" => ["thread", "commented"],
263 "created" => ["thread", "created"],
264 "uid" => ["thread", "uid"],
265 "starred" => ["thread", "starred"],
266 "mention" => ["thread", "mention"],
267 "network" => ["thread", "network"],
268 "contact-id" => ["thread", "contact-id"],
269 "contact-type" => ["ownercontact", "contact-type"],
271 "query" => "FROM `thread`
272 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
273 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
274 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
275 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
276 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
277 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
278 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
279 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
280 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
281 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
282 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
286 "id" => ["contact", "id"],
287 "uid" => ["contact", "uid"],
288 "created" => ["contact", "created"],
289 "updated" => ["contact", "updated"],
290 "self" => ["contact", "self"],
291 "remote_self" => ["contact", "remote_self"],
292 "rel" => ["contact", "rel"],
293 "duplex" => ["contact", "duplex"],
294 "network" => ["contact", "network"],
295 "protocol" => ["contact", "protocol"],
296 "name" => ["contact", "name"],
297 "nick" => ["contact", "nick"],
298 "location" => ["contact", "location"],
299 "about" => ["contact", "about"],
300 "keywords" => ["contact", "keywords"],
301 "gender" => ["contact", "gender"],
302 "xmpp" => ["contact", "xmpp"],
303 "attag" => ["contact", "attag"],
304 "avatar" => ["contact", "avatar"],
305 "photo" => ["contact", "photo"],
306 "thumb" => ["contact", "thumb"],
307 "micro" => ["contact", "micro"],
308 "site-pubkey" => ["contact", "site-pubkey"],
309 "issued-id" => ["contact", "issued-id"],
310 "dfrn-id" => ["contact", "dfrn-id"],
311 "url" => ["contact", "url"],
312 "nurl" => ["contact", "nurl"],
313 "addr" => ["contact", "addr"],
314 "alias" => ["contact", "alias"],
315 "pubkey" => ["contact", "pubkey"],
316 "prvkey" => ["contact", "prvkey"],
317 "batch" => ["contact", "batch"],
318 "request" => ["contact", "request"],
319 "notify" => ["contact", "notify"],
320 "poll" => ["contact", "poll"],
321 "confirm" => ["contact", "confirm"],
322 "poco" => ["contact", "poco"],
323 "aes_allow" => ["contact", "aes_allow"],
324 "ret-aes" => ["contact", "ret-aes"],
325 "usehub" => ["contact", "usehub"],
326 "subhub" => ["contact", "subhub"],
327 "hub-verify" => ["contact", "hub-verify"],
328 "last-update" => ["contact", "last-update"],
329 "success_update" => ["contact", "success_update"],
330 "failure_update" => ["contact", "failure_update"],
331 "name-date" => ["contact", "name-date"],
332 "uri-date" => ["contact", "uri-date"],
333 "avatar-date" => ["contact", "avatar-date"],
334 "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
335 "term-date" => ["contact", "term-date"],
336 "last-item" => ["contact", "last-item"],
337 "priority" => ["contact", "priority"],
338 "blocked" => ["user", "blocked"],
339 "block_reason" => ["contact", "block_reason"],
340 "readonly" => ["contact", "readonly"],
341 "writable" => ["contact", "writable"],
342 "forum" => ["contact", "forum"],
343 "prv" => ["contact", "prv"],
344 "contact-type" => ["contact", "contact-type"],
345 "manually-approve" => ["contact", "manually-approve"],
346 "hidden" => ["contact", "hidden"],
347 "archive" => ["contact", "archive"],
348 "pending" => ["contact", "pending"],
349 "deleted" => ["contact", "deleted"],
350 "unsearchable" => ["contact", "unsearchable"],
351 "sensitive" => ["contact", "sensitive"],
352 "baseurl" => ["contact", "baseurl"],
353 "reason" => ["contact", "reason"],
354 "closeness" => ["contact", "closeness"],
355 "info" => ["contact", "info"],
356 "profile-id" => ["contact", "profile-id"],
357 "bdyear" => ["contact", "bdyear"],
358 "bd" => ["contact", "bd"],
359 "notify_new_posts" => ["contact", "notify_new_posts"],
360 "fetch_further_information" => ["contact", "fetch_further_information"],
361 "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
362 "parent-uid" => ["user", "parent-uid"],
363 "guid" => ["user", "guid"],
364 "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
365 "email" => ["user", "email"],
366 "openid" => ["user", "openid"],
367 "timezone" => ["user", "timezone"],
368 "language" => ["user", "language"],
369 "register_date" => ["user", "register_date"],
370 "login_date" => ["user", "login_date"],
371 "default-location" => ["user", "default-location"],
372 "allow_location" => ["user", "allow_location"],
373 "theme" => ["user", "theme"],
374 "upubkey" => ["user", "pubkey"],
375 "uprvkey" => ["user", "prvkey"],
376 "sprvkey" => ["user", "sprvkey"],
377 "spubkey" => ["user", "spubkey"],
378 "verified" => ["user", "verified"],
379 "blockwall" => ["user", "blockwall"],
380 "hidewall" => ["user", "hidewall"],
381 "blocktags" => ["user", "blocktags"],
382 "unkmail" => ["user", "unkmail"],
383 "cntunkmail" => ["user", "cntunkmail"],
384 "notify-flags" => ["user", "notify-flags"],
385 "page-flags" => ["user", "page-flags"],
386 "account-type" => ["user", "account-type"],
387 "prvnets" => ["user", "prvnets"],
388 "maxreq" => ["user", "maxreq"],
389 "expire" => ["user", "expire"],
390 "account_removed" => ["user", "account_removed"],
391 "account_expired" => ["user", "account_expired"],
392 "account_expires_on" => ["user", "account_expires_on"],
393 "expire_notification_sent" => ["user", "expire_notification_sent"],
394 "def_gid" => ["user", "def_gid"],
395 "allow_cid" => ["user", "allow_cid"],
396 "allow_gid" => ["user", "allow_gid"],
397 "deny_cid" => ["user", "deny_cid"],
398 "deny_gid" => ["user", "deny_gid"],
399 "openidserver" => ["user", "openidserver"],
400 "publish" => ["profile", "publish"],
401 "net-publish" => ["profile", "net-publish"],
402 "hide-friends" => ["profile", "hide-friends"],
403 "prv_keywords" => ["profile", "prv_keywords"],
404 "pub_keywords" => ["profile", "pub_keywords"],
405 "address" => ["profile", "address"],
406 "locality" => ["profile", "locality"],
407 "region" => ["profile", "region"],
408 "postal-code" => ["profile", "postal-code"],
409 "country-name" => ["profile", "country-name"],
410 "homepage" => ["profile", "homepage"],
411 "dob" => ["profile", "dob"],
413 "query" => "FROM `user`
414 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
415 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
419 "id" => ["register", "id"],
420 "hash" => ["register", "hash"],
421 "created" => ["register", "created"],
422 "uid" => ["register", "uid"],
423 "password" => ["register", "password"],
424 "language" => ["register", "language"],
425 "note" => ["register", "note"],
426 "self" => ["contact", "self"],
427 "name" => ["contact", "name"],
428 "url" => ["contact", "url"],
429 "micro" => ["contact", "micro"],
430 "email" => ["user", "email"],
431 "nick" => ["contact", "nick"],
433 "query" => "FROM `register`
434 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
435 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
437 "tag-search-view" => [
439 "uri-id" => ["post-tag", "uri-id"],
440 "iid" => ["item", "id"],
441 "uri" => ["item", "uri"],
442 "guid" => ["item", "guid"],
443 "uid" => ["item", "uid"],
444 "private" => ["item", "private"],
445 "wall" => ["item", "wall"],
446 "origin" => ["item", "origin"],
447 "gravity" => ["item", "gravity"],
448 "received" => ["item", "received"],
449 "name" => ["tag", "name"],
451 "query" => "FROM `post-tag`
452 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
453 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
454 WHERE `post-tag`.`type` = 1"
456 "workerqueue-view" => [
458 "pid" => ["process", "pid"],
459 "priority" => ["workerqueue", "priority"],
461 "query" => "FROM `process`
462 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
463 WHERE NOT `workerqueue`.`done`"