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