liquid_feedback_frontend
view app/main/_prefork/10_init.lua @ 1347:1abf48fc5cd8
Show unit drop down in registration admin
| author | bsw | 
|---|---|
| date | Mon Aug 06 13:10:52 2018 +0200 (2018-08-06) | 
| parents | 32cc544d5a5b | 
| children | cd497eb8fd73 | 
 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.ldap == nil then
    64   config.ldap = {}
    65 end
    67 if config.oauth2 then
    68   local scopes = {
    69     { scope = "authentication", name = { de = "Identität feststellen (nur Screen-Name)", en = "Determine identity (screen name only)" } },
    70     { scope = "identification", name = { de = "Identität feststellen", en = "Determine identity" } },
    71     { scope = "notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen verwenden", en = "Use email address for notifications" } },
    72     { scope = "read_contents", name = { de = "Inhalte lesen", en = "Read content" } },
    73     { scope = "read_authors", name = { de = "Autorennamen lesen", en = "Read author names" } },
    74     { scope = "read_ratings", name = { de = "Bewertungen lesen", en = "Read ratings" } },
    75     { scope = "read_identities", name = { de = "Identitäten lesen", en = "Read identities" } },
    76     { scope = "read_profiles", name = { de = "Profile lesen", en = "Read profiles" } },
    77     { scope = "post", name = { de = "Neue Inhalte veröffentlichen", en = "Post new content" } },
    78     { scope = "rate", name = { de = "Bewertungen vornehmen", en = "Do ratings" } },
    79     { scope = "vote", name = { de = "Abstimmen", en = "Vote" } },
    80     { scope = "delegate", name = { de = "Delegieren", en = "Delegate" } },
    81     { scope = "profile", name = { de = "Eigenes Profil lesen", en = "Read your profile" } },
    82     { scope = "settings", name = { de = "Einstellungen einsehen", en = "Read your settings" } },
    83     { scope = "update_name", name = { de = "Screen-Namen ändern", en = "Update screen name" } },
    84     { scope = "update_notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen ändern", en = "Update notify email address" } },
    85     { scope = "update_profile", name = { de = "Profil bearbeiten", en = "Update your profile" } },
    86     { scope = "update_settings", name = { de = "Benutzereinstellungen ändern", en = "Update your settings" } }   
    87   }
    88   local s = config.oauth2.available_scopes or {}
    89   for i, scope in ipairs(scopes) do
    90     s[#s+1] = scope
    91   end
    92   config.oauth2.available_scopes = s
    93   if not config.oauth2.endpoint_magic then
    94     config.oauth2.endpoint_magic = "liquidfeedback_client/redirection_endpoint"
    95   end
    96   if not config.oauth2.manifest_magic then
    97     config.oauth2.manifest_magic = "liquidfeedback_client/manifest"
    98   end
    99   if not config.oauth2.host_func then
   100     config.oauth2.host_func = function(domain) return extos.pfilter(nil, "host", "-t", "TXT", domain) end
   101   end
   102   if not config.oauth2.authorization_code_lifetime then
   103     config.oauth2.authorization_code_lifetime = 5 * 60
   104   end
   105   if not config.oauth2.refresh_token_lifetime then
   106     config.oauth2.refresh_token_lifetime = 60 * 60 * 24 * 30 * 3
   107   end
   108   if not config.oauth2.refresh_pause then
   109     config.oauth2.refresh_pause = 60
   110   end
   111   if not config.oauth2.refresh_grace_period then
   112     config.oauth2.refresh_grace_period = 60
   113   end
   114   if not config.oauth2.access_token_lifetime then
   115     config.oauth2.access_token_lifetime = 60 * 60
   116   end
   117   if not config.oauth2.dynamic_registration_lifetime then
   118     config.oauth2.dynamic_registration_lifetime = 60 * 60 * 24
   119   end
   120 end
   122 if not config.database then
   123   config.database = { engine='postgresql', dbname='liquid_feedback' }
   124 end
   126 if config.fork == nil then
   127   config.fork = {}
   128 end
   130 if config.fork.pre == nil then
   131   config.fork.pre = 2
   132 end
   134 if config.fork.min == nil then
   135   config.fork.min = 4
   136 end
   138 if config.fork.max == nil then
   139   config.fork.max = 128
   140 end
   142 if config.fork.delay == nil then
   143   config.fork.delay = 0.125
   144 end
   146 if config.fork.error_delay == nil then
   147   config.fork.error_delay = 2
   148 end
   150 if config.fork.exit_delay == nil then
   151   config.fork.exit_delay = 2
   152 end
   154 if config.fork.idle_timeout == nil then
   155   config.fork.idle_timeout = 900
   156 end
   158 if config.port == nil then
   159   config.port = 8080
   160 end
   162 if config.localhost == nil then
   163   config.localhost = true
   164 end
   166 local listen_options = {
   167   pre_fork              = config.fork.pre,
   168   min_fork              = config.fork.min,
   169   max_fork              = config.fork.max,
   170   fork_delay            = config.fork.delay,
   171   fork_error_delay      = config.fork.error_delay,
   172   exit_delay            = config.fork.exit_delay,
   173   idle_timeout          = config.fork.idle_timeout,
   174   memory_limit          = config.fork.memory_limit,
   175   min_requests_per_fork = config.fork.min_requests,
   176   max_requests_per_fork = config.fork.max_requests,
   177   http_options          = config.http_options
   178 }
   180 if config.ipv6 then
   181   local host = config.localhost and "::1" or "::"
   182   listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
   183 end
   184 if config.ipv6 ~= "only" then
   185   local host = config.localhost and "127.0.0.1" or "0.0.0.0"
   186   listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
   187 end
   189 request.set_404_route{ module = 'index', view = '404' }
   191 request.set_absolute_baseurl(config.absolute_base_url)
   193 -- TODO remove style cache
   195 listen(listen_options)
   197 listen{
   198   {
   199     proto = "main",
   200     name = "process_event_stream",
   201     handler = function(poll)
   202       Event:process_stream(poll)
   203     end    
   204   }
   205 }
   207 listen{
   208   {
   209     proto = "interval",
   210     name  = "send_pending_notifications",
   211     delay = 5,
   212     handler = function()
   213       while true do
   214         if not Newsletter:send_next_newsletter() then
   215           break
   216         end
   217       end
   218       while true do
   219         if not InitiativeForNotification:notify_next_member() then
   220           break
   221         end
   222       end
   223     end
   224   },
   225   min_fork = 1,
   226   max_fork = 1
   227 }
   229 execute.inner()
