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