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