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