liquid_feedback_frontend

view app/main/_prefork/10_init.lua @ 1248:c0fd12b97d65

Changes on notifications system, newsletter support added
author bsw
date Tue Apr 05 20:40:37 2016 +0200 (2016-04-05)
parents a3e9e3433852
children 84f6e17c7ceb
line source
1 config.app_version = "3.1.0"
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.enabled_languages == nil then
25 config.enabled_languages = { 'en', 'de', 'ka' } --, 'eo', 'el', 'hu', 'it', 'nl', 'zh-Hans', 'zh-TW' }
26 end
28 if config.default_lang == nil then
29 config.default_lang = "en"
30 end
32 if config.mail_subject_prefix == nil then
33 config.mail_subject_prefix = "[LiquidFeedback] "
34 end
36 if config.member_image_content_type == nil then
37 config.member_image_content_type = "image/jpeg"
38 end
40 if config.member_image_convert_func == nil then
41 config.member_image_convert_func = {
42 avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end,
43 photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
44 }
45 end
47 if config.locked_profile_fields == nil then
48 config.locked_profile_fields = {}
49 end
51 if config.check_delegations_default == nil then
52 config.check_delegations_default = "confirm"
53 end
55 if config.ldap == nil then
56 config.ldap = {}
57 end
59 if not config.database then
60 config.database = { engine='postgresql', dbname='liquid_feedback' }
61 end
63 if config.fork == nil then
64 config.fork = {}
65 end
67 if config.fork.pre == nil then
68 config.fork.pre = 2
69 end
71 if config.fork.min == nil then
72 config.fork.min = 4
73 end
75 if config.fork.max == nil then
76 config.fork.max = 128
77 end
79 if config.fork.delay == nil then
80 config.fork.delay = 0.125
81 end
83 if config.fork.error_delay == nil then
84 config.fork.error_delay = 2
85 end
87 if config.fork.exit_delay == nil then
88 config.fork.exit_delay = 2
89 end
91 if config.fork.idle_timeout == nil then
92 config.fork.idle_timeout = 900
93 end
95 if config.port == nil then
96 config.port = 8080
97 end
99 if config.localhost == nil then
100 config.localhost = true
101 end
103 local listen_options = {
104 pre_fork = config.fork.pre,
105 min_fork = config.fork.min,
106 max_fork = config.fork.max,
107 fork_delay = config.fork.delay,
108 fork_error_delay = config.fork.error_delay,
109 exit_delay = config.fork.exit_delay,
110 idle_timeout = config.fork.idle_timeout,
111 memory_limit = config.fork.memory_limit,
112 min_requests_per_fork = config.fork.min_requests,
113 max_requests_per_fork = config.fork.max_requests,
114 http_options = config.http_options
115 }
117 if config.ipv6 then
118 local host = config.localhost and "::1" or "::"
119 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
120 end
121 if config.ipv6 ~= "only" then
122 local host = config.localhost and "127.0.0.1" or "0.0.0.0"
123 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
124 end
126 request.set_404_route{ module = 'index', view = '404' }
128 request.set_absolute_baseurl(config.absolute_base_url)
130 listen(listen_options)
132 listen{
133 {
134 proto = "interval",
135 name = "send_pending_notifications",
136 delay = 5,
137 handler = function()
138 while true do
139 local did_work = false
140 local tmp
141 tmp = Newsletter:send_next_newsletter()
142 if tmp then did_work = true end
143 tmp = Event:send_next_notification()
144 if tmp then did_work = true end
145 tmp = InitiativeForNotification:notify_next_member()
146 if tmp then did_work = true end
147 if not did_work then
148 break
149 end
150 end
151 end
152 },
153 min_fork = 1,
154 max_fork = 1
155 }
157 execute.inner()

Impressum / About Us