liquid_feedback_frontend

view app/main/_prefork/10_init.lua @ 1250:84f6e17c7ceb

Completed support for new notification system
author bsw
date Sun Apr 17 15:03:44 2016 +0200 (2016-04-17)
parents c0fd12b97d65
children 235a36a08da1
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.notification_digest_template == nil then
37 config.notification_digest_template = "Hello #{name},\n\nthis is your personal digest.\n\n#{digest}\n"
38 end
40 if config.member_image_content_type == nil then
41 config.member_image_content_type = "image/jpeg"
42 end
44 if config.member_image_convert_func == nil then
45 config.member_image_convert_func = {
46 avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end,
47 photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
48 }
49 end
51 if config.locked_profile_fields == nil then
52 config.locked_profile_fields = {}
53 end
55 if config.check_delegations_default == nil then
56 config.check_delegations_default = "confirm"
57 end
59 if config.ldap == nil then
60 config.ldap = {}
61 end
63 if not config.database then
64 config.database = { engine='postgresql', dbname='liquid_feedback' }
65 end
67 if config.fork == nil then
68 config.fork = {}
69 end
71 if config.fork.pre == nil then
72 config.fork.pre = 2
73 end
75 if config.fork.min == nil then
76 config.fork.min = 4
77 end
79 if config.fork.max == nil then
80 config.fork.max = 128
81 end
83 if config.fork.delay == nil then
84 config.fork.delay = 0.125
85 end
87 if config.fork.error_delay == nil then
88 config.fork.error_delay = 2
89 end
91 if config.fork.exit_delay == nil then
92 config.fork.exit_delay = 2
93 end
95 if config.fork.idle_timeout == nil then
96 config.fork.idle_timeout = 900
97 end
99 if config.port == nil then
100 config.port = 8080
101 end
103 if config.localhost == nil then
104 config.localhost = true
105 end
107 local listen_options = {
108 pre_fork = config.fork.pre,
109 min_fork = config.fork.min,
110 max_fork = config.fork.max,
111 fork_delay = config.fork.delay,
112 fork_error_delay = config.fork.error_delay,
113 exit_delay = config.fork.exit_delay,
114 idle_timeout = config.fork.idle_timeout,
115 memory_limit = config.fork.memory_limit,
116 min_requests_per_fork = config.fork.min_requests,
117 max_requests_per_fork = config.fork.max_requests,
118 http_options = config.http_options
119 }
121 if config.ipv6 then
122 local host = config.localhost and "::1" or "::"
123 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
124 end
125 if config.ipv6 ~= "only" then
126 local host = config.localhost and "127.0.0.1" or "0.0.0.0"
127 listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
128 end
130 request.set_404_route{ module = 'index', view = '404' }
132 request.set_absolute_baseurl(config.absolute_base_url)
134 listen(listen_options)
136 listen{
137 {
138 proto = "interval",
139 name = "send_pending_notifications",
140 delay = 5,
141 handler = function()
142 while true do
143 if not Newsletter:send_next_newsletter() then
144 break
145 end
146 end
147 while true do
148 if not Event:send_next_notification() then
149 break
150 end
151 end
152 while true do
153 if not InitiativeForNotification:notify_next_member() then
154 break
155 end
156 end
157 end
158 },
159 min_fork = 1,
160 max_fork = 1
161 }
163 execute.inner()

Impressum / About Us