rev |
line source |
bsw@1844
|
1 config.app_version = "4.0.0-dev"
|
bsw@1222
|
2
|
bsw@1222
|
3 -- TODO abstraction
|
bsw@1222
|
4 -- get record by id
|
bsw@1222
|
5 function mondelefant.class_prototype:by_id(id)
|
bsw@1222
|
6 local selector = self:new_selector()
|
bsw@1222
|
7 selector:add_where{ 'id = ?', id }
|
bsw@1222
|
8 selector:optional_object_mode()
|
bsw@1222
|
9 return selector:exec()
|
bsw@1222
|
10 end
|
bsw@1222
|
11
|
bsw@1222
|
12 if not config.password_hash_algorithm then
|
bsw@1222
|
13 config.password_hash_algorithm = "crypt_sha512"
|
bsw@1222
|
14 end
|
bsw@1222
|
15
|
bsw@1222
|
16 if not config.password_hash_min_rounds then
|
bsw@1222
|
17 config.password_hash_min_rounds = 10000
|
bsw@1222
|
18 end
|
bsw@1222
|
19
|
bsw@1222
|
20 if not config.password_hash_max_rounds then
|
bsw@1222
|
21 config.password_hash_max_rounds = 20000
|
bsw@1222
|
22 end
|
bsw@1222
|
23
|
bsw@1253
|
24 if config.use_terms_checkboxes == nil then
|
bsw@1253
|
25 config.use_terms_checkboxes = {}
|
bsw@1253
|
26 end
|
bsw@1253
|
27
|
bsw@1222
|
28 if config.enabled_languages == nil then
|
bsw@1222
|
29 config.enabled_languages = { 'en', 'de', 'ka' } --, 'eo', 'el', 'hu', 'it', 'nl', 'zh-Hans', 'zh-TW' }
|
bsw@1222
|
30 end
|
bsw@1222
|
31
|
bsw@1222
|
32 if config.default_lang == nil then
|
bsw@1222
|
33 config.default_lang = "en"
|
bsw@1222
|
34 end
|
bsw@1222
|
35
|
bsw@1222
|
36 if config.mail_subject_prefix == nil then
|
bsw@1222
|
37 config.mail_subject_prefix = "[LiquidFeedback] "
|
bsw@1222
|
38 end
|
bsw@1222
|
39
|
bsw@1250
|
40 if config.notification_digest_template == nil then
|
bsw@1798
|
41 config.notification_digest_template = _"Hello #{name},\n\nthis is your personal digest.\n\n#{digest}\n"
|
bsw@1250
|
42 end
|
bsw@1250
|
43
|
bsw@1222
|
44 if config.member_image_content_type == nil then
|
bsw@1222
|
45 config.member_image_content_type = "image/jpeg"
|
bsw@1222
|
46 end
|
bsw@1222
|
47
|
bsw@1222
|
48 if config.member_image_convert_func == nil then
|
bsw@1222
|
49 config.member_image_convert_func = {
|
bsw@1222
|
50 avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end,
|
bsw@1222
|
51 photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
|
bsw@1222
|
52 }
|
bsw@1222
|
53 end
|
bsw@1222
|
54
|
bsw@1222
|
55 if config.locked_profile_fields == nil then
|
bsw@1222
|
56 config.locked_profile_fields = {}
|
bsw@1222
|
57 end
|
bsw@1222
|
58
|
bsw@1222
|
59 if config.check_delegations_default == nil then
|
bsw@1222
|
60 config.check_delegations_default = "confirm"
|
bsw@1222
|
61 end
|
bsw@1222
|
62
|
bsw@1511
|
63 if config.cookie_name == nil then
|
bsw@1511
|
64 config.cookie_name = "liquid_feedback_session"
|
bsw@1511
|
65 end
|
bsw@1511
|
66
|
bsw@1511
|
67 if config.cookie_name_samesite == nil then
|
bsw@1511
|
68 config.cookie_name_samesite = config.cookie_name .. "_samesite"
|
bsw@1511
|
69 end
|
bsw@1511
|
70
|
bsw@1222
|
71 if config.ldap == nil then
|
bsw@1222
|
72 config.ldap = {}
|
bsw@1222
|
73 end
|
bsw@1222
|
74
|
bsw/jbe@1309
|
75 if config.oauth2 then
|
bsw/jbe@1309
|
76 local scopes = {
|
bsw/jbe@1309
|
77 { scope = "authentication", name = { de = "Identität feststellen (nur Screen-Name)", en = "Determine identity (screen name only)" } },
|
bsw/jbe@1309
|
78 { scope = "identification", name = { de = "Identität feststellen", en = "Determine identity" } },
|
bsw/jbe@1309
|
79 { scope = "notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen verwenden", en = "Use email address for notifications" } },
|
bsw/jbe@1309
|
80 { scope = "read_contents", name = { de = "Inhalte lesen", en = "Read content" } },
|
bsw/jbe@1309
|
81 { scope = "read_authors", name = { de = "Autorennamen lesen", en = "Read author names" } },
|
bsw/jbe@1309
|
82 { scope = "read_ratings", name = { de = "Bewertungen lesen", en = "Read ratings" } },
|
bsw/jbe@1309
|
83 { scope = "read_identities", name = { de = "Identitäten lesen", en = "Read identities" } },
|
bsw/jbe@1309
|
84 { scope = "read_profiles", name = { de = "Profile lesen", en = "Read profiles" } },
|
bsw/jbe@1309
|
85 { scope = "post", name = { de = "Neue Inhalte veröffentlichen", en = "Post new content" } },
|
bsw/jbe@1309
|
86 { scope = "rate", name = { de = "Bewertungen vornehmen", en = "Do ratings" } },
|
bsw/jbe@1309
|
87 { scope = "vote", name = { de = "Abstimmen", en = "Vote" } },
|
bsw/jbe@1309
|
88 { scope = "delegate", name = { de = "Delegieren", en = "Delegate" } },
|
bsw/jbe@1309
|
89 { scope = "profile", name = { de = "Eigenes Profil lesen", en = "Read your profile" } },
|
bsw/jbe@1309
|
90 { scope = "settings", name = { de = "Einstellungen einsehen", en = "Read your settings" } },
|
bsw/jbe@1309
|
91 { scope = "update_name", name = { de = "Screen-Namen ändern", en = "Update screen name" } },
|
bsw/jbe@1309
|
92 { scope = "update_notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen ändern", en = "Update notify email address" } },
|
bsw/jbe@1309
|
93 { scope = "update_profile", name = { de = "Profil bearbeiten", en = "Update your profile" } },
|
bsw@1526
|
94 { scope = "update_settings", name = { de = "Benutzereinstellungen ändern", en = "Update your settings" } },
|
bsw@1526
|
95 { scope = "login", name = { de = "Login", en = "Login" } }
|
bsw/jbe@1309
|
96 }
|
bsw/jbe@1309
|
97 local s = config.oauth2.available_scopes or {}
|
bsw/jbe@1309
|
98 for i, scope in ipairs(scopes) do
|
bsw/jbe@1309
|
99 s[#s+1] = scope
|
bsw/jbe@1309
|
100 end
|
bsw/jbe@1309
|
101 config.oauth2.available_scopes = s
|
bsw/jbe@1309
|
102 if not config.oauth2.endpoint_magic then
|
bsw/jbe@1309
|
103 config.oauth2.endpoint_magic = "liquidfeedback_client/redirection_endpoint"
|
bsw/jbe@1309
|
104 end
|
bsw/jbe@1309
|
105 if not config.oauth2.manifest_magic then
|
bsw/jbe@1309
|
106 config.oauth2.manifest_magic = "liquidfeedback_client/manifest"
|
bsw/jbe@1309
|
107 end
|
bsw/jbe@1309
|
108 if not config.oauth2.host_func then
|
bsw/jbe@1309
|
109 config.oauth2.host_func = function(domain) return extos.pfilter(nil, "host", "-t", "TXT", domain) end
|
bsw/jbe@1309
|
110 end
|
bsw/jbe@1309
|
111 if not config.oauth2.authorization_code_lifetime then
|
bsw/jbe@1309
|
112 config.oauth2.authorization_code_lifetime = 5 * 60
|
bsw/jbe@1309
|
113 end
|
bsw/jbe@1309
|
114 if not config.oauth2.refresh_token_lifetime then
|
bsw/jbe@1309
|
115 config.oauth2.refresh_token_lifetime = 60 * 60 * 24 * 30 * 3
|
bsw/jbe@1309
|
116 end
|
bsw/jbe@1309
|
117 if not config.oauth2.refresh_pause then
|
bsw/jbe@1309
|
118 config.oauth2.refresh_pause = 60
|
bsw/jbe@1309
|
119 end
|
bsw/jbe@1309
|
120 if not config.oauth2.refresh_grace_period then
|
bsw/jbe@1309
|
121 config.oauth2.refresh_grace_period = 60
|
bsw/jbe@1309
|
122 end
|
bsw/jbe@1309
|
123 if not config.oauth2.access_token_lifetime then
|
bsw/jbe@1309
|
124 config.oauth2.access_token_lifetime = 60 * 60
|
bsw/jbe@1309
|
125 end
|
bsw/jbe@1309
|
126 if not config.oauth2.dynamic_registration_lifetime then
|
bsw/jbe@1309
|
127 config.oauth2.dynamic_registration_lifetime = 60 * 60 * 24
|
bsw/jbe@1309
|
128 end
|
bsw@1656
|
129 if config.oauth2.refresh_pause < config.oauth2.refresh_grace_period then
|
bsw@1656
|
130 print("ERROR: config.auth2.refresh_pause is smaller than config.oauth2.refresh_grace_period")
|
bsw@1656
|
131 os.exit()
|
bsw@1656
|
132 end
|
bsw/jbe@1309
|
133 end
|
bsw/jbe@1309
|
134
|
bsw@1222
|
135 if not config.database then
|
bsw@1222
|
136 config.database = { engine='postgresql', dbname='liquid_feedback' }
|
bsw@1222
|
137 end
|
bsw@1222
|
138
|
bsw@1648
|
139 if not config.formatting_engines then
|
bsw@1648
|
140 config.enforce_formatting_engine = "html"
|
bsw@1648
|
141 config.formatting_engines = {
|
bsw@1648
|
142 { id = "html",
|
bsw@1648
|
143 name = "html",
|
bsw@1648
|
144 executable = "cat"
|
bsw@1648
|
145 }
|
bsw@1648
|
146 }
|
bsw@1648
|
147 end
|
bsw@1648
|
148
|
bsw@1648
|
149 if not config.style then
|
bsw@1648
|
150 config.style = {
|
bsw@1648
|
151 color_md = {
|
bsw@1648
|
152 primary = "green",
|
bsw@1648
|
153 primary_contrast = "dark",
|
bsw@1648
|
154 accent = "blue",
|
bsw@1648
|
155 accent_contrast = "dark"
|
bsw@1648
|
156 }
|
bsw@1648
|
157 }
|
bsw@1648
|
158 end
|
bsw@1648
|
159
|
bsw@1648
|
160 if not config.member_profile_fields then
|
bsw@1648
|
161 config.member_profile_fields = {}
|
bsw@1648
|
162 end
|
bsw@1648
|
163
|
bsw@1648
|
164
|
jbe@1167
|
165 if config.fork == nil then
|
bsw@1158
|
166 config.fork = {}
|
bsw@1158
|
167 end
|
bsw@1158
|
168
|
jbe@1167
|
169 if config.fork.pre == nil then
|
jbe@1167
|
170 config.fork.pre = 2
|
bsw@1158
|
171 end
|
bsw@1158
|
172
|
jbe@1167
|
173 if config.fork.min == nil then
|
jbe@1167
|
174 config.fork.min = 4
|
jbe@1167
|
175 end
|
jbe@1167
|
176
|
jbe@1167
|
177 if config.fork.max == nil then
|
bsw@1169
|
178 config.fork.max = 128
|
bsw@1158
|
179 end
|
bsw@1158
|
180
|
jbe@1167
|
181 if config.fork.delay == nil then
|
jbe@1167
|
182 config.fork.delay = 0.125
|
jbe@1167
|
183 end
|
jbe@1167
|
184
|
jbe@1167
|
185 if config.fork.error_delay == nil then
|
jbe@1167
|
186 config.fork.error_delay = 2
|
bsw@1158
|
187 end
|
bsw@1158
|
188
|
jbe@1167
|
189 if config.fork.exit_delay == nil then
|
jbe@1167
|
190 config.fork.exit_delay = 2
|
jbe@1167
|
191 end
|
jbe@1167
|
192
|
jbe@1167
|
193 if config.fork.idle_timeout == nil then
|
jbe@1167
|
194 config.fork.idle_timeout = 900
|
jbe@1167
|
195 end
|
jbe@1167
|
196
|
jbe@1167
|
197 if config.port == nil then
|
bsw@1158
|
198 config.port = 8080
|
bsw@1158
|
199 end
|
bsw@1158
|
200
|
bsw@1158
|
201 if config.localhost == nil then
|
bsw@1158
|
202 config.localhost = true
|
bsw@1158
|
203 end
|
bsw@1158
|
204
|
jbe@1167
|
205 local listen_options = {
|
jbe@1167
|
206 pre_fork = config.fork.pre,
|
jbe@1167
|
207 min_fork = config.fork.min,
|
jbe@1167
|
208 max_fork = config.fork.max,
|
jbe@1167
|
209 fork_delay = config.fork.delay,
|
jbe@1167
|
210 fork_error_delay = config.fork.error_delay,
|
jbe@1167
|
211 exit_delay = config.fork.exit_delay,
|
jbe@1167
|
212 idle_timeout = config.fork.idle_timeout,
|
bsw@1169
|
213 memory_limit = config.fork.memory_limit,
|
jbe@1167
|
214 min_requests_per_fork = config.fork.min_requests,
|
jbe@1167
|
215 max_requests_per_fork = config.fork.max_requests,
|
jbe@1167
|
216 http_options = config.http_options
|
jbe@1167
|
217 }
|
jbe@1167
|
218
|
jbe@1167
|
219 if config.ipv6 then
|
bsw@1199
|
220 local host = config.localhost and "::1" or "::"
|
bsw@1199
|
221 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
|
jbe@1167
|
222 end
|
jbe@1167
|
223 if config.ipv6 ~= "only" then
|
bsw@1202
|
224 local host = config.localhost and "127.0.0.1" or "0.0.0.0"
|
bsw@1199
|
225 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
|
jbe@1167
|
226 end
|
jbe@1167
|
227
|
bsw@1222
|
228 request.set_404_route{ module = 'index', view = '404' }
|
bsw@1222
|
229
|
bsw@1222
|
230 request.set_absolute_baseurl(config.absolute_base_url)
|
bsw@1222
|
231
|
bsw/jbe@1309
|
232 -- TODO remove style cache
|
bsw/jbe@1309
|
233
|
jbe@1167
|
234 listen(listen_options)
|
jbe@1167
|
235
|
bsw@1158
|
236 listen{
|
jbe@1167
|
237 {
|
bsw/jbe@1309
|
238 proto = "main",
|
bsw/jbe@1309
|
239 name = "process_event_stream",
|
bsw/jbe@1309
|
240 handler = function(poll)
|
bsw/jbe@1309
|
241 Event:process_stream(poll)
|
bsw/jbe@1309
|
242 end
|
bsw/jbe@1309
|
243 }
|
bsw/jbe@1309
|
244 }
|
bsw/jbe@1309
|
245
|
bsw/jbe@1309
|
246 listen{
|
bsw/jbe@1309
|
247 {
|
jbe@1167
|
248 proto = "interval",
|
jbe@1167
|
249 name = "send_pending_notifications",
|
jbe@1167
|
250 delay = 5,
|
bsw@1248
|
251 handler = function()
|
bsw@1248
|
252 while true do
|
bsw@1250
|
253 if not Newsletter:send_next_newsletter() then
|
bsw@1250
|
254 break
|
bsw@1250
|
255 end
|
bsw@1414
|
256 moonbridge_io.poll(nil, nil, 1)
|
bsw@1250
|
257 end
|
bsw@1250
|
258 while true do
|
bsw@1250
|
259 if not InitiativeForNotification:notify_next_member() then
|
bsw@1248
|
260 break
|
bsw@1248
|
261 end
|
bsw@1414
|
262 moonbridge_io.poll(nil, nil, 1)
|
bsw@1248
|
263 end
|
jbe@1167
|
264 end
|
jbe@1167
|
265 },
|
jbe@1167
|
266 min_fork = 1,
|
jbe@1167
|
267 max_fork = 1
|
bsw@1158
|
268 }
|
bsw@1158
|
269
|
bsw@1533
|
270 if config.firstlife_groups then
|
bsw@1533
|
271 assert(loadcached(encode.file_path(WEBMCP_BASE_PATH, "lib", "firstlife", "groups.lua")))()
|
bsw@1533
|
272 listen{
|
bsw@1533
|
273 {
|
bsw@1533
|
274 proto = "interval",
|
bsw@1753
|
275 name = "mirror_firstlife_groups",
|
bsw@1533
|
276 delay = 5,
|
bsw@1533
|
277 handler = function()
|
bsw@1533
|
278 firstlife_mirror_groups()
|
bsw@1533
|
279 end
|
bsw@1533
|
280 },
|
bsw@1533
|
281 min_fork = 1,
|
bsw@1533
|
282 max_fork = 1
|
bsw@1533
|
283 }
|
bsw@1533
|
284 end
|
bsw@1533
|
285
|
bsw@1850
|
286 if config.token then
|
bsw@1850
|
287 assert(loadcached(encode.file_path(WEBMCP_BASE_PATH, "lib", "token", "sync.lua")))()
|
bsw@1850
|
288 listen{
|
bsw@1850
|
289 {
|
bsw@1850
|
290 proto = "interval",
|
bsw@1850
|
291 name = "sync_token",
|
bsw@1850
|
292 delay = 5,
|
bsw@1850
|
293 handler = function()
|
bsw@1850
|
294 sync_token()
|
bsw@1850
|
295 end
|
bsw@1850
|
296 },
|
bsw@1850
|
297 min_fork = 1,
|
bsw@1850
|
298 max_fork = 1
|
bsw@1850
|
299 }
|
bsw@1850
|
300 end
|
bsw@1850
|
301
|
bsw@1158
|
302 execute.inner()
|
bsw@1158
|
303
|