liquid_feedback_frontend

view app/main/_prefork/10_init.lua @ 1590:8b3375b7f590

Fixed invalid condition for showing action element in issues
author bsw
date Wed Jan 27 10:07:05 2021 +0100 (2021-01-27)
parents d432f85e868e
children 1335379a85d2
line source
1 config.app_version = "4.0.0-pre"
3 -- TODO abstraction
4 -- get record by id
5 function mondelefant.class_prototype:by_id(id)
6 local selector = self:new_selector()
7 selector:add_where{ 'id = ?', id }
8 selector:optional_object_mode()
9 return selector:exec()
10 end
12 if not config.password_hash_algorithm then
13 config.password_hash_algorithm = "crypt_sha512"
14 end
16 if not config.password_hash_min_rounds then
17 config.password_hash_min_rounds = 10000
18 end
20 if not config.password_hash_max_rounds then
21 config.password_hash_max_rounds = 20000
22 end
24 if config.use_terms_checkboxes == nil then
25 config.use_terms_checkboxes = {}
26 end
28 if config.enabled_languages == nil then
29 config.enabled_languages = { 'en', 'de', 'ka' } --, 'eo', 'el', 'hu', 'it', 'nl', 'zh-Hans', 'zh-TW' }
30 end
32 if config.default_lang == nil then
33 config.default_lang = "en"
34 end
36 if config.mail_subject_prefix == nil then
37 config.mail_subject_prefix = "[LiquidFeedback] "
38 end
40 if config.notification_digest_template == nil then
41 config.notification_digest_template = "Hello #{name},\n\nthis is your personal digest.\n\n#{digest}\n"
42 end
44 if config.member_image_content_type == nil then
45 config.member_image_content_type = "image/jpeg"
46 end
48 if config.member_image_convert_func == nil then
49 config.member_image_convert_func = {
50 avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end,
51 photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
52 }
53 end
55 if config.locked_profile_fields == nil then
56 config.locked_profile_fields = {}
57 end
59 if config.check_delegations_default == nil then
60 config.check_delegations_default = "confirm"
61 end
63 if config.cookie_name == nil then
64 config.cookie_name = "liquid_feedback_session"
65 end
67 if config.cookie_name_samesite == nil then
68 config.cookie_name_samesite = config.cookie_name .. "_samesite"
69 end
71 if config.ldap == nil then
72 config.ldap = {}
73 end
75 if config.oauth2 then
76 local scopes = {
77 { scope = "authentication", name = { de = "Identität feststellen (nur Screen-Name)", en = "Determine identity (screen name only)" } },
78 { scope = "identification", name = { de = "Identität feststellen", en = "Determine identity" } },
79 { scope = "notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen verwenden", en = "Use email address for notifications" } },
80 { scope = "read_contents", name = { de = "Inhalte lesen", en = "Read content" } },
81 { scope = "read_authors", name = { de = "Autorennamen lesen", en = "Read author names" } },
82 { scope = "read_ratings", name = { de = "Bewertungen lesen", en = "Read ratings" } },
83 { scope = "read_identities", name = { de = "Identitäten lesen", en = "Read identities" } },
84 { scope = "read_profiles", name = { de = "Profile lesen", en = "Read profiles" } },
85 { scope = "post", name = { de = "Neue Inhalte veröffentlichen", en = "Post new content" } },
86 { scope = "rate", name = { de = "Bewertungen vornehmen", en = "Do ratings" } },
87 { scope = "vote", name = { de = "Abstimmen", en = "Vote" } },
88 { scope = "delegate", name = { de = "Delegieren", en = "Delegate" } },
89 { scope = "profile", name = { de = "Eigenes Profil lesen", en = "Read your profile" } },
90 { scope = "settings", name = { de = "Einstellungen einsehen", en = "Read your settings" } },
91 { scope = "update_name", name = { de = "Screen-Namen ändern", en = "Update screen name" } },
92 { scope = "update_notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen ändern", en = "Update notify email address" } },
93 { scope = "update_profile", name = { de = "Profil bearbeiten", en = "Update your profile" } },
94 { scope = "update_settings", name = { de = "Benutzereinstellungen ändern", en = "Update your settings" } },
95 { scope = "login", name = { de = "Login", en = "Login" } }
96 }
97 local s = config.oauth2.available_scopes or {}
98 for i, scope in ipairs(scopes) do
99 s[#s+1] = scope
100 end
101 config.oauth2.available_scopes = s
102 if not config.oauth2.endpoint_magic then
103 config.oauth2.endpoint_magic = "liquidfeedback_client/redirection_endpoint"
104 end
105 if not config.oauth2.manifest_magic then
106 config.oauth2.manifest_magic = "liquidfeedback_client/manifest"
107 end
108 if not config.oauth2.host_func then
109 config.oauth2.host_func = function(domain) return extos.pfilter(nil, "host", "-t", "TXT", domain) end
110 end
111 if not config.oauth2.authorization_code_lifetime then
112 config.oauth2.authorization_code_lifetime = 5 * 60
113 end
114 if not config.oauth2.refresh_token_lifetime then
115 config.oauth2.refresh_token_lifetime = 60 * 60 * 24 * 30 * 3
116 end
117 if not config.oauth2.refresh_pause then
118 config.oauth2.refresh_pause = 60
119 end
120 if not config.oauth2.refresh_grace_period then
121 config.oauth2.refresh_grace_period = 60
122 end
123 if not config.oauth2.access_token_lifetime then
124 config.oauth2.access_token_lifetime = 60 * 60
125 end
126 if not config.oauth2.dynamic_registration_lifetime then
127 config.oauth2.dynamic_registration_lifetime = 60 * 60 * 24
128 end
129 end
131 if not config.database then
132 config.database = { engine='postgresql', dbname='liquid_feedback' }
133 end
135 if config.fork == nil then
136 config.fork = {}
137 end
139 if config.fork.pre == nil then
140 config.fork.pre = 2
141 end
143 if config.fork.min == nil then
144 config.fork.min = 4
145 end
147 if config.fork.max == nil then
148 config.fork.max = 128
149 end
151 if config.fork.delay == nil then
152 config.fork.delay = 0.125
153 end
155 if config.fork.error_delay == nil then
156 config.fork.error_delay = 2
157 end
159 if config.fork.exit_delay == nil then
160 config.fork.exit_delay = 2
161 end
163 if config.fork.idle_timeout == nil then
164 config.fork.idle_timeout = 900
165 end
167 if config.port == nil then
168 config.port = 8080
169 end
171 if config.localhost == nil then
172 config.localhost = true
173 end
175 local listen_options = {
176 pre_fork = config.fork.pre,
177 min_fork = config.fork.min,
178 max_fork = config.fork.max,
179 fork_delay = config.fork.delay,
180 fork_error_delay = config.fork.error_delay,
181 exit_delay = config.fork.exit_delay,
182 idle_timeout = config.fork.idle_timeout,
183 memory_limit = config.fork.memory_limit,
184 min_requests_per_fork = config.fork.min_requests,
185 max_requests_per_fork = config.fork.max_requests,
186 http_options = config.http_options
187 }
189 if config.ipv6 then
190 local host = config.localhost and "::1" or "::"
191 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
192 end
193 if config.ipv6 ~= "only" then
194 local host = config.localhost and "127.0.0.1" or "0.0.0.0"
195 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
196 end
198 request.set_404_route{ module = 'index', view = '404' }
200 request.set_absolute_baseurl(config.absolute_base_url)
202 -- TODO remove style cache
204 listen(listen_options)
206 listen{
207 {
208 proto = "main",
209 name = "process_event_stream",
210 handler = function(poll)
211 Event:process_stream(poll)
212 end
213 }
214 }
216 listen{
217 {
218 proto = "interval",
219 name = "send_pending_notifications",
220 delay = 5,
221 handler = function()
222 while true do
223 if not Newsletter:send_next_newsletter() then
224 break
225 end
226 moonbridge_io.poll(nil, nil, 1)
227 end
228 while true do
229 if not InitiativeForNotification:notify_next_member() then
230 break
231 end
232 moonbridge_io.poll(nil, nil, 1)
233 end
234 end
235 },
236 min_fork = 1,
237 max_fork = 1
238 }
240 if config.firstlife_groups then
241 assert(loadcached(encode.file_path(WEBMCP_BASE_PATH, "lib", "firstlife", "groups.lua")))()
242 listen{
243 {
244 proto = "interval",
245 name = "send_pending_notifications",
246 delay = 5,
247 handler = function()
248 firstlife_mirror_groups()
249 end
250 },
251 min_fork = 1,
252 max_fork = 1
253 }
254 end
256 execute.inner()

Impressum / About Us