| rev | 
   line source | 
| 
bsw/jbe@1309
 | 
     1 config.app_version = "4.0.0-pre"
 | 
| 
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@1250
 | 
    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/jbe@1309
 | 
   129 end
 | 
| 
bsw/jbe@1309
 | 
   130 
 | 
| 
bsw@1222
 | 
   131 if not config.database then
 | 
| 
bsw@1222
 | 
   132   config.database = { engine='postgresql', dbname='liquid_feedback' }
 | 
| 
bsw@1222
 | 
   133 end
 | 
| 
bsw@1222
 | 
   134 
 | 
| 
jbe@1167
 | 
   135 if config.fork == nil then
 | 
| 
bsw@1158
 | 
   136   config.fork = {}
 | 
| 
bsw@1158
 | 
   137 end
 | 
| 
bsw@1158
 | 
   138 
 | 
| 
jbe@1167
 | 
   139 if config.fork.pre == nil then
 | 
| 
jbe@1167
 | 
   140   config.fork.pre = 2
 | 
| 
bsw@1158
 | 
   141 end
 | 
| 
bsw@1158
 | 
   142 
 | 
| 
jbe@1167
 | 
   143 if config.fork.min == nil then
 | 
| 
jbe@1167
 | 
   144   config.fork.min = 4
 | 
| 
jbe@1167
 | 
   145 end
 | 
| 
jbe@1167
 | 
   146 
 | 
| 
jbe@1167
 | 
   147 if config.fork.max == nil then
 | 
| 
bsw@1169
 | 
   148   config.fork.max = 128
 | 
| 
bsw@1158
 | 
   149 end
 | 
| 
bsw@1158
 | 
   150 
 | 
| 
jbe@1167
 | 
   151 if config.fork.delay == nil then
 | 
| 
jbe@1167
 | 
   152   config.fork.delay = 0.125
 | 
| 
jbe@1167
 | 
   153 end
 | 
| 
jbe@1167
 | 
   154 
 | 
| 
jbe@1167
 | 
   155 if config.fork.error_delay == nil then
 | 
| 
jbe@1167
 | 
   156   config.fork.error_delay = 2
 | 
| 
bsw@1158
 | 
   157 end
 | 
| 
bsw@1158
 | 
   158 
 | 
| 
jbe@1167
 | 
   159 if config.fork.exit_delay == nil then
 | 
| 
jbe@1167
 | 
   160   config.fork.exit_delay = 2
 | 
| 
jbe@1167
 | 
   161 end
 | 
| 
jbe@1167
 | 
   162 
 | 
| 
jbe@1167
 | 
   163 if config.fork.idle_timeout == nil then
 | 
| 
jbe@1167
 | 
   164   config.fork.idle_timeout = 900
 | 
| 
jbe@1167
 | 
   165 end
 | 
| 
jbe@1167
 | 
   166 
 | 
| 
jbe@1167
 | 
   167 if config.port == nil then
 | 
| 
bsw@1158
 | 
   168   config.port = 8080
 | 
| 
bsw@1158
 | 
   169 end
 | 
| 
bsw@1158
 | 
   170 
 | 
| 
bsw@1158
 | 
   171 if config.localhost == nil then
 | 
| 
bsw@1158
 | 
   172   config.localhost = true
 | 
| 
bsw@1158
 | 
   173 end
 | 
| 
bsw@1158
 | 
   174 
 | 
| 
jbe@1167
 | 
   175 local listen_options = {
 | 
| 
jbe@1167
 | 
   176   pre_fork              = config.fork.pre,
 | 
| 
jbe@1167
 | 
   177   min_fork              = config.fork.min,
 | 
| 
jbe@1167
 | 
   178   max_fork              = config.fork.max,
 | 
| 
jbe@1167
 | 
   179   fork_delay            = config.fork.delay,
 | 
| 
jbe@1167
 | 
   180   fork_error_delay      = config.fork.error_delay,
 | 
| 
jbe@1167
 | 
   181   exit_delay            = config.fork.exit_delay,
 | 
| 
jbe@1167
 | 
   182   idle_timeout          = config.fork.idle_timeout,
 | 
| 
bsw@1169
 | 
   183   memory_limit          = config.fork.memory_limit,
 | 
| 
jbe@1167
 | 
   184   min_requests_per_fork = config.fork.min_requests,
 | 
| 
jbe@1167
 | 
   185   max_requests_per_fork = config.fork.max_requests,
 | 
| 
jbe@1167
 | 
   186   http_options          = config.http_options
 | 
| 
jbe@1167
 | 
   187 }
 | 
| 
jbe@1167
 | 
   188 
 | 
| 
jbe@1167
 | 
   189 if config.ipv6 then
 | 
| 
bsw@1199
 | 
   190   local host = config.localhost and "::1" or "::"
 | 
| 
bsw@1199
 | 
   191   listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
 | 
| 
jbe@1167
 | 
   192 end
 | 
| 
jbe@1167
 | 
   193 if config.ipv6 ~= "only" then
 | 
| 
bsw@1202
 | 
   194   local host = config.localhost and "127.0.0.1" or "0.0.0.0"
 | 
| 
bsw@1199
 | 
   195   listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
 | 
| 
jbe@1167
 | 
   196 end
 | 
| 
jbe@1167
 | 
   197 
 | 
| 
bsw@1222
 | 
   198 request.set_404_route{ module = 'index', view = '404' }
 | 
| 
bsw@1222
 | 
   199 
 | 
| 
bsw@1222
 | 
   200 request.set_absolute_baseurl(config.absolute_base_url)
 | 
| 
bsw@1222
 | 
   201 
 | 
| 
bsw/jbe@1309
 | 
   202 -- TODO remove style cache
 | 
| 
bsw/jbe@1309
 | 
   203 
 | 
| 
jbe@1167
 | 
   204 listen(listen_options)
 | 
| 
jbe@1167
 | 
   205 
 | 
| 
bsw@1158
 | 
   206 listen{
 | 
| 
jbe@1167
 | 
   207   {
 | 
| 
bsw/jbe@1309
 | 
   208     proto = "main",
 | 
| 
bsw/jbe@1309
 | 
   209     name = "process_event_stream",
 | 
| 
bsw/jbe@1309
 | 
   210     handler = function(poll)
 | 
| 
bsw/jbe@1309
 | 
   211       Event:process_stream(poll)
 | 
| 
bsw/jbe@1309
 | 
   212     end    
 | 
| 
bsw/jbe@1309
 | 
   213   }
 | 
| 
bsw/jbe@1309
 | 
   214 }
 | 
| 
bsw/jbe@1309
 | 
   215 
 | 
| 
bsw/jbe@1309
 | 
   216 listen{
 | 
| 
bsw/jbe@1309
 | 
   217   {
 | 
| 
jbe@1167
 | 
   218     proto = "interval",
 | 
| 
jbe@1167
 | 
   219     name  = "send_pending_notifications",
 | 
| 
jbe@1167
 | 
   220     delay = 5,
 | 
| 
bsw@1248
 | 
   221     handler = function()
 | 
| 
bsw@1248
 | 
   222       while true do
 | 
| 
bsw@1250
 | 
   223         if not Newsletter:send_next_newsletter() then
 | 
| 
bsw@1250
 | 
   224           break
 | 
| 
bsw@1250
 | 
   225         end
 | 
| 
bsw@1414
 | 
   226         moonbridge_io.poll(nil, nil, 1)
 | 
| 
bsw@1250
 | 
   227       end
 | 
| 
bsw@1250
 | 
   228       while true do
 | 
| 
bsw@1250
 | 
   229         if not InitiativeForNotification:notify_next_member() then
 | 
| 
bsw@1248
 | 
   230           break
 | 
| 
bsw@1248
 | 
   231         end
 | 
| 
bsw@1414
 | 
   232         moonbridge_io.poll(nil, nil, 1)
 | 
| 
bsw@1248
 | 
   233       end
 | 
| 
jbe@1167
 | 
   234     end
 | 
| 
jbe@1167
 | 
   235   },
 | 
| 
jbe@1167
 | 
   236   min_fork = 1,
 | 
| 
jbe@1167
 | 
   237   max_fork = 1
 | 
| 
bsw@1158
 | 
   238 }
 | 
| 
bsw@1158
 | 
   239 
 | 
| 
bsw@1158
 | 
   240 execute.inner()
 | 
| 
bsw@1158
 | 
   241 
 |