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 "group-id" => ["group_member", "gid"],
124 "author-id" => ["item", "author-id"],
125 "author-link" => ["author", "url"],
126 "author-addr" => ["author", "addr"],
127 "author-name" => "IF (`contact`.`url` = `author`.`url`, `contact`.`name`, `author`.`name`)",
128 "author-nick" => ["author", "nick"],
129 "author-avatar" => "IF (`contact`.`url` = `author`.`url`, `contact`.`thumb`, `author`.`thumb`)",
130 "author-network" => ["author", "network"],
131 "author-blocked" => ["author", "blocked"],
132 "author-hidden" => ["author", "hidden"],
133 "owner-id" => ["item", "owner-id"],
134 "owner-link" => ["owner", "url"],
135 "owner-addr" => ["owner", "addr"],
136 "owner-name" => "IF (`contact`.`url` = `owner`.`url`, `contact`.`name`, `owner`.`name`)",
137 "owner-nick" => ["owner", "nick"],
138 "owner-avatar" => "IF (`contact`.`url` = `owner`.`url`, `contact`.`thumb`, `owner`.`thumb`)",
139 "owner-network" => ["owner", "network"],
140 "owner-blocked" => ["owner", "blocked"],
141 "owner-hidden" => ["owner", "hidden"],
142 "causer-id" => ["item", "causer-id"],
143 "causer-link" => ["causer", "url"],
144 "causer-addr" => ["causer", "addr"],
145 "causer-name" => ["causer", "name"],
146 "causer-nick" => ["causer", "nick"],
147 "causer-avatar" => ["causer", "thumb"],
148 "causer-network" => ["causer", "network"],
149 "causer-blocked" => ["causer", "blocked"],
150 "causer-hidden" => ["causer", "hidden"],
151 "causer-contact-type" => ["causer", "contact-type"],
152 "postopts" => ["post-delivery-data", "postopts"],
153 "inform" => ["post-delivery-data", "inform"],
154 "delivery_queue_count" => ["post-delivery-data", "queue_count"],
155 "delivery_queue_done" => ["post-delivery-data", "queue_done"],
156 "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
157 "allow_cid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
158 "allow_gid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
159 "deny_cid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
160 "deny_gid" => "IF (`item`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
161 "event-id" => ["item", "event-id"],
162 "event-created" => ["event", "created"],
163 "event-edited" => ["event", "edited"],
164 "event-start" => ["event", "start"],
165 "event-finish" => ["event", "finish"],
166 "event-summary" => ["event", "summary"],
167 "event-desc" => ["event", "desc"],
168 "event-location" => ["event", "location"],
169 "event-type" => ["event", "type"],
170 "event-nofinish" => ["event", "nofinish"],
171 "event-adjust" => ["event", "adjust"],
172 "event-ignore" => ["event", "ignore"],
173 "signed_text" => ["diaspora-interaction", "interaction"],
174 "parent-guid" => ["parent-item", "guid"],
175 "parent-network" => ["parent-item", "network"],
176 "parent-author-id" => ["parent-item", "author-id"],
177 "parent-author-link" => ["parent-item-author", "url"],
178 "parent-author-name" => ["parent-item-author", "name"],
179 "parent-author-network" => ["parent-item-author", "network"],
181 "query" => "FROM `item`
182 STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
183 STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
184 STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
185 STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id`
186 LEFT JOIN `group_member` ON `group_member`.`contact-id` = `item`.`contact-id`
187 LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid`
188 LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
189 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
190 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
191 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
192 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
193 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id` AND `parent-item`.`uid` = `item`.`uid`
194 STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`"
198 "uri-id" => ["post-category", "uri-id"],
199 "uid" => ["post-category", "uid"],
200 "uri" => ["item-uri", "uri"],
201 "guid" => ["item-uri", "guid"],
202 "type" => ["post-category", "type"],
203 "tid" => ["post-category", "tid"],
204 "name" => ["tag", "name"],
205 "url" => ["tag", "url"],
207 "query" => "FROM `post-category`
208 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
209 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
213 "uri-id" => ["post-tag", "uri-id"],
214 "uri" => ["item-uri", "uri"],
215 "guid" => ["item-uri", "guid"],
216 "type" => ["post-tag", "type"],
217 "tid" => ["post-tag", "tid"],
218 "cid" => ["post-tag", "cid"],
219 "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
220 "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
222 "query" => "FROM `post-tag`
223 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
224 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
225 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
227 "network-item-view" => [
229 "uri-id" => ["item", "parent-uri-id"],
230 "uri" => ["item", "parent-uri"],
231 "parent" => ["item", "parent"],
232 "received" => ["item", "received"],
233 "commented" => ["item", "commented"],
234 "created" => ["item", "created"],
235 "uid" => ["item", "uid"],
236 "starred" => ["item", "starred"],
237 "mention" => ["item", "mention"],
238 "network" => ["item", "network"],
239 "unseen" => ["item", "unseen"],
240 "gravity" => ["item", "gravity"],
241 "contact-id" => ["item", "contact-id"],
242 "contact-type" => ["ownercontact", "contact-type"],
244 "query" => "FROM `item`
245 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
246 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
247 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
248 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
249 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
250 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
251 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
252 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
253 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
254 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
255 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
257 "network-thread-view" => [
259 "uri-id" => ["item", "uri-id"],
260 "uri" => ["item", "uri"],
261 "parent-uri-id" => ["item", "parent-uri-id"],
262 "parent" => ["thread", "iid"],
263 "received" => ["thread", "received"],
264 "commented" => ["thread", "commented"],
265 "created" => ["thread", "created"],
266 "uid" => ["thread", "uid"],
267 "starred" => ["thread", "starred"],
268 "mention" => ["thread", "mention"],
269 "network" => ["thread", "network"],
270 "contact-id" => ["thread", "contact-id"],
271 "contact-type" => ["ownercontact", "contact-type"],
273 "query" => "FROM `thread`
274 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
275 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
276 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
277 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
278 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
279 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
280 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
281 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
282 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
283 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
284 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
288 "id" => ["contact", "id"],
289 "uid" => ["contact", "uid"],
290 "created" => ["contact", "created"],
291 "updated" => ["contact", "updated"],
292 "self" => ["contact", "self"],
293 "remote_self" => ["contact", "remote_self"],
294 "rel" => ["contact", "rel"],
295 "duplex" => ["contact", "duplex"],
296 "network" => ["contact", "network"],
297 "protocol" => ["contact", "protocol"],
298 "name" => ["contact", "name"],
299 "nick" => ["contact", "nick"],
300 "location" => ["contact", "location"],
301 "about" => ["contact", "about"],
302 "keywords" => ["contact", "keywords"],
303 "gender" => ["contact", "gender"],
304 "xmpp" => ["contact", "xmpp"],
305 "attag" => ["contact", "attag"],
306 "avatar" => ["contact", "avatar"],
307 "photo" => ["contact", "photo"],
308 "thumb" => ["contact", "thumb"],
309 "micro" => ["contact", "micro"],
310 "site-pubkey" => ["contact", "site-pubkey"],
311 "issued-id" => ["contact", "issued-id"],
312 "dfrn-id" => ["contact", "dfrn-id"],
313 "url" => ["contact", "url"],
314 "nurl" => ["contact", "nurl"],
315 "addr" => ["contact", "addr"],
316 "alias" => ["contact", "alias"],
317 "pubkey" => ["contact", "pubkey"],
318 "prvkey" => ["contact", "prvkey"],
319 "batch" => ["contact", "batch"],
320 "request" => ["contact", "request"],
321 "notify" => ["contact", "notify"],
322 "poll" => ["contact", "poll"],
323 "confirm" => ["contact", "confirm"],
324 "poco" => ["contact", "poco"],
325 "aes_allow" => ["contact", "aes_allow"],
326 "ret-aes" => ["contact", "ret-aes"],
327 "usehub" => ["contact", "usehub"],
328 "subhub" => ["contact", "subhub"],
329 "hub-verify" => ["contact", "hub-verify"],
330 "last-update" => ["contact", "last-update"],
331 "success_update" => ["contact", "success_update"],
332 "failure_update" => ["contact", "failure_update"],
333 "name-date" => ["contact", "name-date"],
334 "uri-date" => ["contact", "uri-date"],
335 "avatar-date" => ["contact", "avatar-date"],
336 "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
337 "term-date" => ["contact", "term-date"],
338 "last-item" => ["contact", "last-item"],
339 "priority" => ["contact", "priority"],
340 "blocked" => ["user", "blocked"],
341 "block_reason" => ["contact", "block_reason"],
342 "readonly" => ["contact", "readonly"],
343 "writable" => ["contact", "writable"],
344 "forum" => ["contact", "forum"],
345 "prv" => ["contact", "prv"],
346 "contact-type" => ["contact", "contact-type"],
347 "manually-approve" => ["contact", "manually-approve"],
348 "hidden" => ["contact", "hidden"],
349 "archive" => ["contact", "archive"],
350 "pending" => ["contact", "pending"],
351 "deleted" => ["contact", "deleted"],
352 "unsearchable" => ["contact", "unsearchable"],
353 "sensitive" => ["contact", "sensitive"],
354 "baseurl" => ["contact", "baseurl"],
355 "reason" => ["contact", "reason"],
356 "closeness" => ["contact", "closeness"],
357 "info" => ["contact", "info"],
358 "profile-id" => ["contact", "profile-id"],
359 "bdyear" => ["contact", "bdyear"],
360 "bd" => ["contact", "bd"],
361 "notify_new_posts" => ["contact", "notify_new_posts"],
362 "fetch_further_information" => ["contact", "fetch_further_information"],
363 "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
364 "parent-uid" => ["user", "parent-uid"],
365 "guid" => ["user", "guid"],
366 "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
367 "email" => ["user", "email"],
368 "openid" => ["user", "openid"],
369 "timezone" => ["user", "timezone"],
370 "language" => ["user", "language"],
371 "register_date" => ["user", "register_date"],
372 "login_date" => ["user", "login_date"],
373 "default-location" => ["user", "default-location"],
374 "allow_location" => ["user", "allow_location"],
375 "theme" => ["user", "theme"],
376 "upubkey" => ["user", "pubkey"],
377 "uprvkey" => ["user", "prvkey"],
378 "sprvkey" => ["user", "sprvkey"],
379 "spubkey" => ["user", "spubkey"],
380 "verified" => ["user", "verified"],
381 "blockwall" => ["user", "blockwall"],
382 "hidewall" => ["user", "hidewall"],
383 "blocktags" => ["user", "blocktags"],
384 "unkmail" => ["user", "unkmail"],
385 "cntunkmail" => ["user", "cntunkmail"],
386 "notify-flags" => ["user", "notify-flags"],
387 "page-flags" => ["user", "page-flags"],
388 "account-type" => ["user", "account-type"],
389 "prvnets" => ["user", "prvnets"],
390 "maxreq" => ["user", "maxreq"],
391 "expire" => ["user", "expire"],
392 "account_removed" => ["user", "account_removed"],
393 "account_expired" => ["user", "account_expired"],
394 "account_expires_on" => ["user", "account_expires_on"],
395 "expire_notification_sent" => ["user", "expire_notification_sent"],
396 "def_gid" => ["user", "def_gid"],
397 "allow_cid" => ["user", "allow_cid"],
398 "allow_gid" => ["user", "allow_gid"],
399 "deny_cid" => ["user", "deny_cid"],
400 "deny_gid" => ["user", "deny_gid"],
401 "openidserver" => ["user", "openidserver"],
402 "publish" => ["profile", "publish"],
403 "net-publish" => ["profile", "net-publish"],
404 "hide-friends" => ["profile", "hide-friends"],
405 "prv_keywords" => ["profile", "prv_keywords"],
406 "pub_keywords" => ["profile", "pub_keywords"],
407 "address" => ["profile", "address"],
408 "locality" => ["profile", "locality"],
409 "region" => ["profile", "region"],
410 "postal-code" => ["profile", "postal-code"],
411 "country-name" => ["profile", "country-name"],
412 "homepage" => ["profile", "homepage"],
413 "dob" => ["profile", "dob"],
415 "query" => "FROM `user`
416 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
417 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
421 "id" => ["register", "id"],
422 "hash" => ["register", "hash"],
423 "created" => ["register", "created"],
424 "uid" => ["register", "uid"],
425 "password" => ["register", "password"],
426 "language" => ["register", "language"],
427 "note" => ["register", "note"],
428 "self" => ["contact", "self"],
429 "name" => ["contact", "name"],
430 "url" => ["contact", "url"],
431 "micro" => ["contact", "micro"],
432 "email" => ["user", "email"],
433 "nick" => ["contact", "nick"],
435 "query" => "FROM `register`
436 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
437 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
439 "tag-search-view" => [
441 "uri-id" => ["post-tag", "uri-id"],
442 "iid" => ["item", "id"],
443 "uri" => ["item", "uri"],
444 "guid" => ["item", "guid"],
445 "uid" => ["item", "uid"],
446 "private" => ["item", "private"],
447 "wall" => ["item", "wall"],
448 "origin" => ["item", "origin"],
449 "gravity" => ["item", "gravity"],
450 "received" => ["item", "received"],
451 "name" => ["tag", "name"],
453 "query" => "FROM `post-tag`
454 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
455 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
456 WHERE `post-tag`.`type` = 1"
458 "workerqueue-view" => [
460 "pid" => ["process", "pid"],
461 "priority" => ["workerqueue", "priority"],
463 "query" => "FROM `process`
464 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
465 WHERE NOT `workerqueue`.`done`"