bsw/jbe@1309: config.app_version = "4.0.0-pre" bsw@1222: bsw@1222: -- TODO abstraction bsw@1222: -- get record by id bsw@1222: function mondelefant.class_prototype:by_id(id) bsw@1222: local selector = self:new_selector() bsw@1222: selector:add_where{ 'id = ?', id } bsw@1222: selector:optional_object_mode() bsw@1222: return selector:exec() bsw@1222: end bsw@1222: bsw@1222: if not config.password_hash_algorithm then bsw@1222: config.password_hash_algorithm = "crypt_sha512" bsw@1222: end bsw@1222: bsw@1222: if not config.password_hash_min_rounds then bsw@1222: config.password_hash_min_rounds = 10000 bsw@1222: end bsw@1222: bsw@1222: if not config.password_hash_max_rounds then bsw@1222: config.password_hash_max_rounds = 20000 bsw@1222: end bsw@1222: bsw@1253: if config.use_terms_checkboxes == nil then bsw@1253: config.use_terms_checkboxes = {} bsw@1253: end bsw@1253: bsw@1222: if config.enabled_languages == nil then bsw@1222: config.enabled_languages = { 'en', 'de', 'ka' } --, 'eo', 'el', 'hu', 'it', 'nl', 'zh-Hans', 'zh-TW' } bsw@1222: end bsw@1222: bsw@1222: if config.default_lang == nil then bsw@1222: config.default_lang = "en" bsw@1222: end bsw@1222: bsw@1222: if config.mail_subject_prefix == nil then bsw@1222: config.mail_subject_prefix = "[LiquidFeedback] " bsw@1222: end bsw@1222: bsw@1250: if config.notification_digest_template == nil then bsw@1250: config.notification_digest_template = "Hello #{name},\n\nthis is your personal digest.\n\n#{digest}\n" bsw@1250: end bsw@1250: bsw@1222: if config.member_image_content_type == nil then bsw@1222: config.member_image_content_type = "image/jpeg" bsw@1222: end bsw@1222: bsw@1222: if config.member_image_convert_func == nil then bsw@1222: config.member_image_convert_func = { bsw@1222: avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end, bsw@1222: photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end bsw@1222: } bsw@1222: end bsw@1222: bsw@1222: if config.locked_profile_fields == nil then bsw@1222: config.locked_profile_fields = {} bsw@1222: end bsw@1222: bsw@1222: if config.check_delegations_default == nil then bsw@1222: config.check_delegations_default = "confirm" bsw@1222: end bsw@1222: bsw@1511: if config.cookie_name == nil then bsw@1511: config.cookie_name = "liquid_feedback_session" bsw@1511: end bsw@1511: bsw@1511: if config.cookie_name_samesite == nil then bsw@1511: config.cookie_name_samesite = config.cookie_name .. "_samesite" bsw@1511: end bsw@1511: bsw@1222: if config.ldap == nil then bsw@1222: config.ldap = {} bsw@1222: end bsw@1222: bsw/jbe@1309: if config.oauth2 then bsw/jbe@1309: local scopes = { bsw/jbe@1309: { scope = "authentication", name = { de = "Identität feststellen (nur Screen-Name)", en = "Determine identity (screen name only)" } }, bsw/jbe@1309: { scope = "identification", name = { de = "Identität feststellen", en = "Determine identity" } }, bsw/jbe@1309: { scope = "notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen verwenden", en = "Use email address for notifications" } }, bsw/jbe@1309: { scope = "read_contents", name = { de = "Inhalte lesen", en = "Read content" } }, bsw/jbe@1309: { scope = "read_authors", name = { de = "Autorennamen lesen", en = "Read author names" } }, bsw/jbe@1309: { scope = "read_ratings", name = { de = "Bewertungen lesen", en = "Read ratings" } }, bsw/jbe@1309: { scope = "read_identities", name = { de = "Identitäten lesen", en = "Read identities" } }, bsw/jbe@1309: { scope = "read_profiles", name = { de = "Profile lesen", en = "Read profiles" } }, bsw/jbe@1309: { scope = "post", name = { de = "Neue Inhalte veröffentlichen", en = "Post new content" } }, bsw/jbe@1309: { scope = "rate", name = { de = "Bewertungen vornehmen", en = "Do ratings" } }, bsw/jbe@1309: { scope = "vote", name = { de = "Abstimmen", en = "Vote" } }, bsw/jbe@1309: { scope = "delegate", name = { de = "Delegieren", en = "Delegate" } }, bsw/jbe@1309: { scope = "profile", name = { de = "Eigenes Profil lesen", en = "Read your profile" } }, bsw/jbe@1309: { scope = "settings", name = { de = "Einstellungen einsehen", en = "Read your settings" } }, bsw/jbe@1309: { scope = "update_name", name = { de = "Screen-Namen ändern", en = "Update screen name" } }, bsw/jbe@1309: { scope = "update_notify_email", name = { de = "E-Mail-Adresse für Benachrichtigungen ändern", en = "Update notify email address" } }, bsw/jbe@1309: { scope = "update_profile", name = { de = "Profil bearbeiten", en = "Update your profile" } }, bsw/jbe@1309: { scope = "update_settings", name = { de = "Benutzereinstellungen ändern", en = "Update your settings" } } bsw/jbe@1309: } bsw/jbe@1309: local s = config.oauth2.available_scopes or {} bsw/jbe@1309: for i, scope in ipairs(scopes) do bsw/jbe@1309: s[#s+1] = scope bsw/jbe@1309: end bsw/jbe@1309: config.oauth2.available_scopes = s bsw/jbe@1309: if not config.oauth2.endpoint_magic then bsw/jbe@1309: config.oauth2.endpoint_magic = "liquidfeedback_client/redirection_endpoint" bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.manifest_magic then bsw/jbe@1309: config.oauth2.manifest_magic = "liquidfeedback_client/manifest" bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.host_func then bsw/jbe@1309: config.oauth2.host_func = function(domain) return extos.pfilter(nil, "host", "-t", "TXT", domain) end bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.authorization_code_lifetime then bsw/jbe@1309: config.oauth2.authorization_code_lifetime = 5 * 60 bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.refresh_token_lifetime then bsw/jbe@1309: config.oauth2.refresh_token_lifetime = 60 * 60 * 24 * 30 * 3 bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.refresh_pause then bsw/jbe@1309: config.oauth2.refresh_pause = 60 bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.refresh_grace_period then bsw/jbe@1309: config.oauth2.refresh_grace_period = 60 bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.access_token_lifetime then bsw/jbe@1309: config.oauth2.access_token_lifetime = 60 * 60 bsw/jbe@1309: end bsw/jbe@1309: if not config.oauth2.dynamic_registration_lifetime then bsw/jbe@1309: config.oauth2.dynamic_registration_lifetime = 60 * 60 * 24 bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: bsw@1222: if not config.database then bsw@1222: config.database = { engine='postgresql', dbname='liquid_feedback' } bsw@1222: end bsw@1222: jbe@1167: if config.fork == nil then bsw@1158: config.fork = {} bsw@1158: end bsw@1158: jbe@1167: if config.fork.pre == nil then jbe@1167: config.fork.pre = 2 bsw@1158: end bsw@1158: jbe@1167: if config.fork.min == nil then jbe@1167: config.fork.min = 4 jbe@1167: end jbe@1167: jbe@1167: if config.fork.max == nil then bsw@1169: config.fork.max = 128 bsw@1158: end bsw@1158: jbe@1167: if config.fork.delay == nil then jbe@1167: config.fork.delay = 0.125 jbe@1167: end jbe@1167: jbe@1167: if config.fork.error_delay == nil then jbe@1167: config.fork.error_delay = 2 bsw@1158: end bsw@1158: jbe@1167: if config.fork.exit_delay == nil then jbe@1167: config.fork.exit_delay = 2 jbe@1167: end jbe@1167: jbe@1167: if config.fork.idle_timeout == nil then jbe@1167: config.fork.idle_timeout = 900 jbe@1167: end jbe@1167: jbe@1167: if config.port == nil then bsw@1158: config.port = 8080 bsw@1158: end bsw@1158: bsw@1158: if config.localhost == nil then bsw@1158: config.localhost = true bsw@1158: end bsw@1158: jbe@1167: local listen_options = { jbe@1167: pre_fork = config.fork.pre, jbe@1167: min_fork = config.fork.min, jbe@1167: max_fork = config.fork.max, jbe@1167: fork_delay = config.fork.delay, jbe@1167: fork_error_delay = config.fork.error_delay, jbe@1167: exit_delay = config.fork.exit_delay, jbe@1167: idle_timeout = config.fork.idle_timeout, bsw@1169: memory_limit = config.fork.memory_limit, jbe@1167: min_requests_per_fork = config.fork.min_requests, jbe@1167: max_requests_per_fork = config.fork.max_requests, jbe@1167: http_options = config.http_options jbe@1167: } jbe@1167: jbe@1167: if config.ipv6 then bsw@1199: local host = config.localhost and "::1" or "::" bsw@1199: listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port } jbe@1167: end jbe@1167: if config.ipv6 ~= "only" then bsw@1202: local host = config.localhost and "127.0.0.1" or "0.0.0.0" bsw@1199: listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port } jbe@1167: end jbe@1167: bsw@1222: request.set_404_route{ module = 'index', view = '404' } bsw@1222: bsw@1222: request.set_absolute_baseurl(config.absolute_base_url) bsw@1222: bsw/jbe@1309: -- TODO remove style cache bsw/jbe@1309: jbe@1167: listen(listen_options) jbe@1167: bsw@1158: listen{ jbe@1167: { bsw/jbe@1309: proto = "main", bsw/jbe@1309: name = "process_event_stream", bsw/jbe@1309: handler = function(poll) bsw/jbe@1309: Event:process_stream(poll) bsw/jbe@1309: end bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: listen{ bsw/jbe@1309: { jbe@1167: proto = "interval", jbe@1167: name = "send_pending_notifications", jbe@1167: delay = 5, bsw@1248: handler = function() bsw@1248: while true do bsw@1250: if not Newsletter:send_next_newsletter() then bsw@1250: break bsw@1250: end bsw@1414: moonbridge_io.poll(nil, nil, 1) bsw@1250: end bsw@1250: while true do bsw@1250: if not InitiativeForNotification:notify_next_member() then bsw@1248: break bsw@1248: end bsw@1414: moonbridge_io.poll(nil, nil, 1) bsw@1248: end jbe@1167: end jbe@1167: }, jbe@1167: min_fork = 1, jbe@1167: max_fork = 1 bsw@1158: } bsw@1158: bsw@1158: execute.inner() bsw@1158: