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 "type" => ["item", "type"],
55 "wall" => ["item", "wall"],
56 "gravity" => ["item", "gravity"],
57 "extid" => ["item", "extid"],
58 "iaid" => ["item", "iaid"],
59 "icid" => ["item", "icid"],
60 "psid" => ["item", "psid"],
61 "created" => ["item", "created"],
62 "edited" => ["item", "edited"],
63 "commented" => ["item", "commented"],
64 "received" => ["item", "received"],
65 "changed" => ["item", "changed"],
66 "verb" => ["item-content", "verb"],
67 "plink" => ["item-content", "plink"],
68 "language" => ["item-content", "language"],
69 "resource-id" => ["item", "resource-id"],
70 "event-id" => ["item", "event-id"],
71 "attach" => ["item", "attach"],
72 "postopts" => ["post-delivery-data", "postopts"],
73 "inform" => ["post-delivery-data", "inform"],
75 "allow_cid" => ["permissionset", "allow_cid"],
76 "allow_gid" => ["permissionset", "allow_gid"],
77 "deny_cid" => ["permissionset", "deny_cid"],
78 "deny_gid" => ["permissionset", "deny_gid"],
79 "post-type" => ["item", "post-type"],
80 "private" => ["item", "private"],
81 "pubmail" => ["item", "pubmail"],
82 "moderated" => ["item", "moderated"],
83 "visible" => ["item", "visible"],
84 "starred" => ["item", "starred"],
85 "bookmark" => ["thread", "bookmark"],
86 "unseen" => ["item", "unseen"],
87 "deleted" => ["item", "deleted"],
88 "origin" => ["item", "origin"],
89 "forum_mode" => ["item", "forum_mode"],
90 "mention" => ["item", "mention"],
91 "global" => ["item", "global"],
92 "network" => ["item", "network"],
93 "title" => ["item-content", "title"],
94 "content-warning" => ["item-content", "content-warning"],
95 "body" => ["item-content", "body"],
96 "location" => ["item-content", "location"],
97 "coord" => ["item-content", "coord"],
98 "app" => ["item-content", "app"],
99 "rendered-hash" => ["item-content", "rendered-hash"],
100 "rendered-html" => ["item-content", "rendered-html"],
101 "object-type" => ["item-content", "object-type"],
102 "object" => ["item-content", "object"],
103 "target-type" => ["item-content", "target-type"],
104 "target" => ["item-content", "target"],
105 "author-id" => ["item", "author-id"],
106 "author-link" => ["author", "url"],
107 "author-name" => ["author", "name"],
108 "author-avatar" => ["author", "thumb"],
109 "author-network" => ["author", "network"],
110 "owner-id" => ["item", "owner-id"],
111 "owner-link" => ["owner", "url"],
112 "owner-addr" => ["owner", "addr"],
113 "owner-avatar" => ["owner", "thumb"],
114 "owner-nick" => ["owner", "nick"],
115 "owner-name" => ["owner", "name"],
116 "owner-network" => ["owner", "network"],
117 "contact-uid" => ["contact", "uid"],
118 "parent-guid" => ["parent-item", "guid"],
119 "parent-network" => ["parent-item", "network"],
120 "signed_text" => ["diaspora-interaction", "interaction"],
121 "signature" => "NULL",
124 "query" => "FROM `item`
125 LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
126 LEFT JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
127 LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
128 LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
129 LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id`
130 LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
131 LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
132 LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
133 LEFT JOIN `thread` ON `thread`.`iid` = `item`.`parent`
134 STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`"
138 "uri-id" => ["post-category", "uri-id"],
139 "uid" => ["post-category", "uid"],
140 "uri" => ["item-uri", "uri"],
141 "guid" => ["item-uri", "guid"],
142 "type" => ["post-category", "type"],
143 "tid" => ["post-category", "tid"],
144 "name" => ["tag", "name"],
145 "url" => ["tag", "url"],
147 "query" => "FROM `post-category`
148 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
149 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
153 "uri-id" => ["post-tag", "uri-id"],
154 "uri" => ["item-uri", "uri"],
155 "guid" => ["item-uri", "guid"],
156 "type" => ["post-tag", "type"],
157 "tid" => ["post-tag", "tid"],
158 "cid" => ["post-tag", "cid"],
159 "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
160 "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
162 "query" => "FROM `post-tag`
163 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
164 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
165 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
169 "id" => ["contact", "id"],
170 "uid" => ["contact", "uid"],
171 "created" => ["contact", "created"],
172 "updated" => ["contact", "updated"],
173 "self" => ["contact", "self"],
174 "remote_self" => ["contact", "remote_self"],
175 "rel" => ["contact", "rel"],
176 "duplex" => ["contact", "duplex"],
177 "network" => ["contact", "network"],
178 "protocol" => ["contact", "protocol"],
179 "name" => ["contact", "name"],
180 "nick" => ["contact", "nick"],
181 "location" => ["contact", "location"],
182 "about" => ["contact", "about"],
183 "keywords" => ["contact", "keywords"],
184 "gender" => ["contact", "gender"],
185 "xmpp" => ["contact", "xmpp"],
186 "attag" => ["contact", "attag"],
187 "avatar" => ["contact", "avatar"],
188 "photo" => ["contact", "photo"],
189 "thumb" => ["contact", "thumb"],
190 "micro" => ["contact", "micro"],
191 "site-pubkey" => ["contact", "site-pubkey"],
192 "issued-id" => ["contact", "issued-id"],
193 "dfrn-id" => ["contact", "dfrn-id"],
194 "url" => ["contact", "url"],
195 "nurl" => ["contact", "nurl"],
196 "addr" => ["contact", "addr"],
197 "alias" => ["contact", "alias"],
198 "pubkey" => ["contact", "pubkey"],
199 "prvkey" => ["contact", "prvkey"],
200 "batch" => ["contact", "batch"],
201 "request" => ["contact", "request"],
202 "notify" => ["contact", "notify"],
203 "poll" => ["contact", "poll"],
204 "confirm" => ["contact", "confirm"],
205 "poco" => ["contact", "poco"],
206 "aes_allow" => ["contact", "aes_allow"],
207 "ret-aes" => ["contact", "ret-aes"],
208 "usehub" => ["contact", "usehub"],
209 "subhub" => ["contact", "subhub"],
210 "hub-verify" => ["contact", "hub-verify"],
211 "last-update" => ["contact", "last-update"],
212 "success_update" => ["contact", "success_update"],
213 "failure_update" => ["contact", "failure_update"],
214 "name-date" => ["contact", "name-date"],
215 "uri-date" => ["contact", "uri-date"],
216 "avatar-date" => ["contact", "avatar-date"],
217 "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
218 "term-date" => ["contact", "term-date"],
219 "last-item" => ["contact", "last-item"],
220 "priority" => ["contact", "priority"],
221 "blocked" => ["contact", "blocked"], /// @todo Check if "blocked" from contact or from the users table
222 "block_reason" => ["contact", "block_reason"],
223 "readonly" => ["contact", "readonly"],
224 "writable" => ["contact", "writable"],
225 "forum" => ["contact", "forum"],
226 "prv" => ["contact", "prv"],
227 "contact-type" => ["contact", "contact-type"],
228 "hidden" => ["contact", "hidden"],
229 "archive" => ["contact", "archive"],
230 "pending" => ["contact", "pending"],
231 "deleted" => ["contact", "deleted"],
232 "rating" => ["contact", "rating"],
233 "unsearchable" => ["contact", "unsearchable"],
234 "sensitive" => ["contact", "sensitive"],
235 "baseurl" => ["contact", "baseurl"],
236 "reason" => ["contact", "reason"],
237 "closeness" => ["contact", "closeness"],
238 "info" => ["contact", "info"],
239 "profile-id" => ["contact", "profile-id"],
240 "bdyear" => ["contact", "bdyear"],
241 "bd" => ["contact", "bd"],
242 "notify_new_posts" => ["contact", "notify_new_posts"],
243 "fetch_further_information" => ["contact", "fetch_further_information"],
244 "ffi_keyword_blacklist" => ["contact", "ffi_keyword_blacklist"],
245 "parent-uid" => ["user", "parent-uid"],
246 "guid" => ["user", "guid"],
247 "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
248 "email" => ["user", "email"],
249 "openid" => ["user", "openid"],
250 "timezone" => ["user", "timezone"],
251 "language" => ["user", "language"],
252 "register_date" => ["user", "register_date"],
253 "login_date" => ["user", "login_date"],
254 "default-location" => ["user", "default-location"],
255 "allow_location" => ["user", "allow_location"],
256 "theme" => ["user", "theme"],
257 "upubkey" => ["user", "pubkey"],
258 "uprvkey" => ["user", "prvkey"],
259 "sprvkey" => ["user", "sprvkey"],
260 "spubkey" => ["user", "spubkey"],
261 "verified" => ["user", "verified"],
262 "blockwall" => ["user", "blockwall"],
263 "hidewall" => ["user", "hidewall"],
264 "blocktags" => ["user", "blocktags"],
265 "unkmail" => ["user", "unkmail"],
266 "cntunkmail" => ["user", "cntunkmail"],
267 "notify-flags" => ["user", "notify-flags"],
268 "page-flags" => ["user", "page-flags"],
269 "account-type" => ["user", "account-type"],
270 "prvnets" => ["user", "prvnets"],
271 "maxreq" => ["user", "maxreq"],
272 "expire" => ["user", "expire"],
273 "account_removed" => ["user", "account_removed"],
274 "account_expired" => ["user", "account_expired"],
275 "account_expires_on" => ["user", "account_expires_on"],
276 "expire_notification_sent" => ["user", "expire_notification_sent"],
277 "def_gid" => ["user", "def_gid"],
278 "allow_cid" => ["user", "allow_cid"],
279 "allow_gid" => ["user", "allow_gid"],
280 "deny_cid" => ["user", "deny_cid"],
281 "deny_gid" => ["user", "deny_gid"],
282 "openidserver" => ["user", "openidserver"],
283 "publish" => ["profile", "publish"],
284 "net-publish" => ["profile", "net-publish"],
285 "hide-friends" => ["profile", "hide-friends"],
286 "prv_keywords" => ["profile", "prv_keywords"],
287 "pub_keywords" => ["profile", "pub_keywords"],
288 "address" => ["profile", "address"],
289 "locality" => ["profile", "locality"],
290 "region" => ["profile", "region"],
291 "postal-code" => ["profile", "postal-code"],
292 "country-name" => ["profile", "country-name"],
293 "homepage" => ["profile", "homepage"],
294 "dob" => ["profile", "dob"],
296 "query" => "FROM `user`
297 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
298 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
302 "id" => ["register", "id"],
303 "hash" => ["register", "hash"],
304 "created" => ["register", "created"],
305 "uid" => ["register", "uid"],
306 "password" => ["register", "password"],
307 "language" => ["register", "language"],
308 "note" => ["register", "note"],
309 "self" => ["contact", "self"],
310 "name" => ["contact", "name"],
311 "url" => ["contact", "url"],
312 "micro" => ["contact", "micro"],
313 "email" => ["user", "email"],
314 "nick" => ["contact", "nick"],
316 "query" => "FROM `register`
317 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
318 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
320 "tag-search-view" => [
322 "uri-id" => ["post-tag", "uri-id"],
323 "iid" => ["item", "id"],
324 "uri" => ["item", "uri"],
325 "guid" => ["item", "guid"],
326 "uid" => ["item", "uid"],
327 "private" => ["item", "private"],
328 "wall" => ["item", "wall"],
329 "origin" => ["item", "origin"],
330 "gravity" => ["item", "gravity"],
331 "received" => ["item", "received"],
332 "name" => ["tag", "name"],
334 "query" => "FROM `post-tag`
335 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
336 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
337 WHERE `post-tag`.`type` = 1"
339 "workerqueue-view" => [
341 "pid" => ["process", "pid"],
342 "priority" => ["workerqueue", "priority"],
344 "query" => "FROM `process`
345 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
346 WHERE NOT `workerqueue`.`done`"