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 "uri-id" => ["post-category", "uri-id"],
43 "uid" => ["post-category", "uid"],
44 "uri" => ["item-uri", "uri"],
45 "guid" => ["item-uri", "guid"],
46 "type" => ["post-category", "type"],
47 "tid" => ["post-category", "tid"],
48 "name" => ["tag", "name"],
49 "url" => ["tag", "url"],
51 "query" => "FROM `post-category`
52 INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
53 LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
57 "uri-id" => ["post-tag", "uri-id"],
58 "uri" => ["item-uri", "uri"],
59 "guid" => ["item-uri", "guid"],
60 "type" => ["post-tag", "type"],
61 "tid" => ["post-tag", "tid"],
62 "cid" => ["post-tag", "cid"],
63 "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
64 "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
66 "query" => "FROM `post-tag`
67 INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
68 LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
69 LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
71 "network-thread-view" => [
73 "uri-id" => ["item", "uri-id"],
74 "uri" => ["item", "uri"],
75 "parent-uri-id" => ["item", "parent-uri-id"],
76 "parent" => ["thread", "iid"],
77 "item_id" => ["thread", "iid"],
78 "received" => ["thread", "received"],
79 "commented" => ["thread", "commented"],
80 "created" => ["thread", "created"],
81 "uid" => ["thread", "uid"],
82 "starred" => ["thread", "starred"],
83 "mention" => ["thread", "mention"],
84 "network" => ["thread", "network"],
85 "contact-id" => ["thread", "contact-id"],
87 "query" => "FROM `thread`
88 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`)
89 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
90 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
91 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
92 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
93 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
94 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
95 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
96 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
98 "network-item-view" => [
100 "uri-id" => ["item", "parent-uri-id"],
101 "uri" => ["item", "parent-uri"],
102 "parent" => ["item", "parent"],
103 "item_id" => ["item", "parent"],
104 "received" => ["item", "received"],
105 "commented" => ["item", "commented"],
106 "created" => ["item", "created"],
107 "uid" => ["item", "uid"],
108 "starred" => ["item", "starred"],
109 "mention" => ["item", "mention"],
110 "network" => ["item", "network"],
111 "unseen" => ["item", "unseen"],
112 "gravity" => ["item", "gravity"],
113 "contact-id" => ["item", "contact-id"],
115 "query" => "FROM `item`
116 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
117 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`)
118 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
119 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
120 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
121 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
122 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
123 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
124 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
128 "id" => ["contact", "id"],
129 "uid" => ["contact", "uid"],
130 "created" => ["contact", "created"],
131 "updated" => ["contact", "updated"],
132 "self" => ["contact", "self"],
133 "remote_self" => ["contact", "remote_self"],
134 "rel" => ["contact", "rel"],
135 "duplex" => ["contact", "duplex"],
136 "network" => ["contact", "network"],
137 "protocol" => ["contact", "protocol"],
138 "name" => ["contact", "name"],
139 "nick" => ["contact", "nick"],
140 "location" => ["contact", "location"],
141 "about" => ["contact", "about"],
142 "keywords" => ["contact", "keywords"],
143 "gender" => ["contact", "gender"],
144 "xmpp" => ["contact", "xmpp"],
145 "attag" => ["contact", "attag"],
146 "avatar" => ["contact", "avatar"],
147 "photo" => ["contact", "photo"],
148 "thumb" => ["contact", "thumb"],
149 "micro" => ["contact", "micro"],
150 "site-pubkey" => ["contact", "site-pubkey"],
151 "issued-id" => ["contact", "issued-id"],
152 "dfrn-id" => ["contact", "dfrn-id"],
153 "url" => ["contact", "url"],
154 "nurl" => ["contact", "nurl"],
155 "addr" => ["contact", "addr"],
156 "alias" => ["contact", "alias"],
157 "pubkey" => ["contact", "pubkey"],
158 "prvkey" => ["contact", "prvkey"],
159 "batch" => ["contact", "batch"],
160 "request" => ["contact", "request"],
161 "notify" => ["contact", "notify"],
162 "poll" => ["contact", "poll"],
163 "confirm" => ["contact", "confirm"],
164 "poco" => ["contact", "poco"],
165 "aes_allow" => ["contact", "aes_allow"],
166 "ret-aes" => ["contact", "ret-aes"],
167 "usehub" => ["contact", "usehub"],
168 "subhub" => ["contact", "subhub"],
169 "hub-verify" => ["contact", "hub-verify"],
170 "last-update" => ["contact", "last-update"],
171 "success_update" => ["contact", "success_update"],
172 "failure_update" => ["contact", "failure_update"],
173 "name-date" => ["contact", "name-date"],
174 "uri-date" => ["contact", "uri-date"],
175 "avatar-date" => ["contact", "avatar-date"],
176 "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
177 "term-date" => ["contact", "term-date"],
178 "last-item" => ["contact", "last-item"],
179 "priority" => ["contact", "priority"],
180 "blocked" => ["contact", "blocked"], /// @todo Check if "blocked" from contact or from the users table
181 "block_reason" => ["contact", "block_reason"],
182 "readonly" => ["contact", "readonly"],
183 "writable" => ["contact", "writable"],
184 "forum" => ["contact", "forum"],
185 "prv" => ["contact", "prv"],
186 "contact-type" => ["contact", "contact-type"],
187 "hidden" => ["contact", "hidden"],
188 "archive" => ["contact", "archive"],
189 "pending" => ["contact", "pending"],
190 "deleted" => ["contact", "deleted"],
191 "rating" => ["contact", "rating"],
192 "unsearchable" => ["contact", "unsearchable"],
193 "sensitive" => ["contact", "sensitive"],
194 "baseurl" => ["contact", "baseurl"],
195 "reason" => ["contact", "reason"],
196 "closeness" => ["contact", "closeness"],
197 "info" => ["contact", "info"],
198 "profile-id" => ["contact", "profile-id"],
199 "bdyear" => ["contact", "bdyear"],
200 "bd" => ["contact", "bd"],
201 "notify_new_posts" => ["contact", "notify_new_posts"],
202 "fetch_further_information" => ["contact", "fetch_further_information"],
203 "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
204 "parent-uid" => ["user", "parent-uid"],
205 "guid" => ["user", "guid"],
206 "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
207 "email" => ["user", "email"],
208 "openid" => ["user", "openid"],
209 "timezone" => ["user", "timezone"],
210 "language" => ["user", "language"],
211 "register_date" => ["user", "register_date"],
212 "login_date" => ["user", "login_date"],
213 "default-location" => ["user", "default-location"],
214 "allow_location" => ["user", "allow_location"],
215 "theme" => ["user", "theme"],
216 "upubkey" => ["user", "pubkey"],
217 "uprvkey" => ["user", "prvkey"],
218 "sprvkey" => ["user", "sprvkey"],
219 "spubkey" => ["user", "spubkey"],
220 "verified" => ["user", "verified"],
221 "blockwall" => ["user", "blockwall"],
222 "hidewall" => ["user", "hidewall"],
223 "blocktags" => ["user", "blocktags"],
224 "unkmail" => ["user", "unkmail"],
225 "cntunkmail" => ["user", "cntunkmail"],
226 "notify-flags" => ["user", "notify-flags"],
227 "page-flags" => ["user", "page-flags"],
228 "account-type" => ["user", "account-type"],
229 "prvnets" => ["user", "prvnets"],
230 "maxreq" => ["user", "maxreq"],
231 "expire" => ["user", "expire"],
232 "account_removed" => ["user", "account_removed"],
233 "account_expired" => ["user", "account_expired"],
234 "account_expires_on" => ["user", "account_expires_on"],
235 "expire_notification_sent" => ["user", "expire_notification_sent"],
236 "def_gid" => ["user", "def_gid"],
237 "allow_cid" => ["user", "allow_cid"],
238 "allow_gid" => ["user", "allow_gid"],
239 "deny_cid" => ["user", "deny_cid"],
240 "deny_gid" => ["user", "deny_gid"],
241 "openidserver" => ["user", "openidserver"],
242 "publish" => ["profile", "publish"],
243 "net-publish" => ["profile", "net-publish"],
244 "hide-friends" => ["profile", "hide-friends"],
245 "prv_keywords" => ["profile", "prv_keywords"],
246 "pub_keywords" => ["profile", "pub_keywords"],
247 "address" => ["profile", "address"],
248 "locality" => ["profile", "locality"],
249 "region" => ["profile", "region"],
250 "postal-code" => ["profile", "postal-code"],
251 "country-name" => ["profile", "country-name"],
252 "homepage" => ["profile", "homepage"],
253 "dob" => ["profile", "dob"],
255 "query" => "FROM `user`
256 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
257 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
261 "id" => ["register", "id"],
262 "hash" => ["register", "hash"],
263 "created" => ["register", "created"],
264 "uid" => ["register", "uid"],
265 "password" => ["register", "password"],
266 "language" => ["register", "language"],
267 "note" => ["register", "note"],
268 "self" => ["contact", "self"],
269 "name" => ["contact", "name"],
270 "url" => ["contact", "url"],
271 "micro" => ["contact", "micro"],
272 "email" => ["user", "email"],
273 "nick" => ["contact", "nick"],
275 "query" => "FROM `register`
276 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
277 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
279 "tag-search-view" => [
281 "uri-id" => ["post-tag", "uri-id"],
282 "iid" => ["item", "id"],
283 "uri" => ["item", "uri"],
284 "guid" => ["item", "guid"],
285 "uid" => ["item", "uid"],
286 "private" => ["item", "private"],
287 "wall" => ["item", "wall"],
288 "origin" => ["item", "origin"],
289 "gravity" => ["item", "gravity"],
290 "received" => ["item", "received"],
291 "name" => ["tag", "name"],
293 "query" => "FROM `post-tag`
294 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
295 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
296 WHERE `post-tag`.`type` = 1"
298 "workerqueue-view" => [
300 "pid" => ["process", "pid"],
301 "priority" => ["workerqueue", "priority"],
303 "query" => "FROM `process`
304 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
305 WHERE NOT `workerqueue`.`done`"