Use PagesEnabled struct when setting pages_enabled

The config update logic for the admin panel was not updated to use
the `PagesEnabled` struct introduced in commit `e238624`
This commit is contained in:
syeopite 2025-08-24 23:12:20 -07:00
parent ba65e4ff25
commit d496b6e34a
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
2 changed files with 6 additions and 5 deletions

View File

@ -79,6 +79,8 @@ struct PagesEnabled
property popular : Bool = true property popular : Bool = true
property search : Bool = true property search : Bool = true
def initialize(@trending, @popular, @search); end
def has_key?(key : String) : Bool def has_key?(key : String) : Bool
%w(trending popular search).includes?(key) %w(trending popular search).includes?(key)
end end

View File

@ -199,12 +199,11 @@ module Invidious::Routes::PreferencesRoute
end end
CONFIG.default_user_preferences.feed_menu = admin_feed_menu CONFIG.default_user_preferences.feed_menu = admin_feed_menu
pages_enabled = { CONFIG.pages_enabled = PagesEnabled.new(
popular: (env.params.body["popular_enabled"]?.try &.as(String) || "on") == "on", popular: (env.params.body["popular_enabled"]?.try &.as(String) || "on") == "on",
trending: (env.params.body["trending_enabled"]?.try &.as(String) || "on") == "on", trending: (env.params.body["trending_enabled"]?.try &.as(String) || "on") == "on",
search: (env.params.body["search_enabled"]?.try &.as(String) || "on") == "on", search: (env.params.body["search_enabled"]?.try &.as(String) || "on") == "on",
} )
CONFIG.pages_enabled = pages_enabled
captcha_enabled = env.params.body["captcha_enabled"]?.try &.as(String) captcha_enabled = env.params.body["captcha_enabled"]?.try &.as(String)
captcha_enabled ||= "off" captcha_enabled ||= "off"