forked from e621ng/e621ng
[Cleanup] Remove readonly only
Since its introduction 3 years ago, it got used once I believe I can't even say if this properly works anymore. If something like that is actually desired in the future, it should just be a whitelist instead
This commit is contained in:
parent
6b2b2cfc14
commit
56e849695b
@ -1,6 +1,5 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
class APIThrottled < Exception; end
|
||||
class ReadOnlyException < Exception; end
|
||||
class FeatureUnavailable < StandardError; end
|
||||
|
||||
skip_forgery_protection if: -> { SessionLoader.new(request).has_api_authentication? || request.options? }
|
||||
@ -9,7 +8,6 @@ class ApplicationController < ActionController::Base
|
||||
before_action :normalize_search
|
||||
before_action :api_check
|
||||
before_action :enable_cors
|
||||
before_action :enforce_readonly
|
||||
after_action :reset_current_user
|
||||
layout "default"
|
||||
|
||||
@ -83,8 +81,6 @@ class ApplicationController < ActionController::Base
|
||||
render_error_page(503, exception, message: "The database is unavailable. Try again later.")
|
||||
when ActionController::ParameterMissing
|
||||
render_expected_error(400, exception.message)
|
||||
when ReadOnlyException
|
||||
render_expected_error(400, exception.message)
|
||||
when BCrypt::Errors::InvalidHash
|
||||
render_expected_error(400, "You must reset your password.")
|
||||
else
|
||||
@ -220,13 +216,4 @@ class ApplicationController < ActionController::Base
|
||||
def permit_search_params(permitted_params)
|
||||
params.fetch(:search, {}).permit([:id, :created_at, :updated_at] + permitted_params)
|
||||
end
|
||||
|
||||
def enforce_readonly
|
||||
return unless Danbooru.config.readonly_mode?
|
||||
raise ReadOnlyException.new "The site is in readonly mode" unless allowed_readonly_actions.include? action_name
|
||||
end
|
||||
|
||||
def allowed_readonly_actions
|
||||
%w[index show search]
|
||||
end
|
||||
end
|
||||
|
@ -38,7 +38,7 @@ class ForumTopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
if request.format == Mime::Type.lookup("text/html") && !Danbooru.config.readonly_mode?
|
||||
if request.format == Mime::Type.lookup("text/html")
|
||||
@forum_topic.mark_as_read!(CurrentUser.user)
|
||||
end
|
||||
@forum_posts = ForumPost.includes(topic: [:category]).search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page])
|
||||
|
@ -80,8 +80,4 @@ class PoolsController < ApplicationController
|
||||
permitted_params = %i[name description category is_active post_ids post_ids_string]
|
||||
params.require(:pool).permit(*permitted_params, post_ids: [])
|
||||
end
|
||||
|
||||
def allowed_readonly_actions
|
||||
super + ["gallery"]
|
||||
end
|
||||
end
|
||||
|
@ -173,8 +173,4 @@ class PostsController < ApplicationController
|
||||
|
||||
params.require(:post).permit(permitted_params)
|
||||
end
|
||||
|
||||
def allowed_readonly_actions
|
||||
super + %w[random show_seq]
|
||||
end
|
||||
end
|
||||
|
@ -26,10 +26,4 @@ class SessionsController < ApplicationController
|
||||
cookies.delete :remember
|
||||
redirect_to(posts_path, :notice => "You are now logged out")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def allowed_readonly_actions
|
||||
super + %w[destroy]
|
||||
end
|
||||
end
|
||||
|
@ -33,7 +33,7 @@ class StaticController < ApplicationController
|
||||
end
|
||||
|
||||
def disable_mobile_mode
|
||||
if CurrentUser.is_member? && !Danbooru.config.readonly_mode?
|
||||
if CurrentUser.is_member?
|
||||
user = CurrentUser.user
|
||||
user.disable_responsive_mode = !user.disable_responsive_mode
|
||||
user.save
|
||||
@ -62,7 +62,4 @@ class StaticController < ApplicationController
|
||||
redirect_to(Danbooru.config.discord_site + user_hash, allow_other_host: true)
|
||||
end
|
||||
end
|
||||
|
||||
def enforce_readonly
|
||||
end
|
||||
end
|
||||
|
@ -140,8 +140,4 @@ class UsersController < ApplicationController
|
||||
permitted_params += %i[ip_addr email_matches] if CurrentUser.is_admin?
|
||||
permit_search_params permitted_params
|
||||
end
|
||||
|
||||
def allowed_readonly_actions
|
||||
super + %w[home upload_limit]
|
||||
end
|
||||
end
|
||||
|
@ -2,8 +2,6 @@ module Maintenance
|
||||
module_function
|
||||
|
||||
def daily
|
||||
return if Danbooru.config.readonly_mode?
|
||||
|
||||
ignoring_exceptions { PostPruner.new.prune! }
|
||||
ignoring_exceptions { Upload.where('created_at < ?', 1.week.ago).delete_all }
|
||||
ignoring_exceptions { ForumSubscription.process_all! }
|
||||
|
@ -23,7 +23,7 @@ class SessionLoader
|
||||
load_remember_token
|
||||
end
|
||||
|
||||
CurrentUser.user.unban! if CurrentUser.user.ban_expired? && !Danbooru.config.readonly_mode?
|
||||
CurrentUser.user.unban! if CurrentUser.user.ban_expired?
|
||||
if CurrentUser.user.is_blocked?
|
||||
recent_ban = CurrentUser.user.recent_ban
|
||||
ban_message = "Account is banned: forever"
|
||||
@ -33,8 +33,8 @@ class SessionLoader
|
||||
raise AuthenticationFailure.new(ban_message)
|
||||
end
|
||||
set_statement_timeout
|
||||
update_last_logged_in_at unless Danbooru.config.readonly_mode?
|
||||
update_last_ip_addr unless Danbooru.config.readonly_mode?
|
||||
update_last_logged_in_at
|
||||
update_last_ip_addr
|
||||
set_time_zone
|
||||
set_safe_mode
|
||||
refresh_old_remember_token
|
||||
|
@ -184,8 +184,6 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def mark_as_read!
|
||||
return if Danbooru.config.readonly_mode?
|
||||
|
||||
update_column(:is_read, true)
|
||||
owner.dmails.unread.count.tap do |unread_count|
|
||||
owner.update(has_mail: (unread_count > 0), unread_dmail_count: unread_count)
|
||||
@ -193,8 +191,6 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def mark_as_unread!
|
||||
return if Danbooru.config.readonly_mode?
|
||||
|
||||
update_column(:is_read, false)
|
||||
owner.dmails.unread.count.tap do |unread_count|
|
||||
owner.update(has_mail: (unread_count > 0), unread_dmail_count: unread_count)
|
||||
|
@ -108,7 +108,7 @@ class ForumTopic < ApplicationRecord
|
||||
end
|
||||
|
||||
def mark_as_read!(user = CurrentUser.user)
|
||||
return if user.is_anonymous? || Danbooru.config.readonly_mode?
|
||||
return if user.is_anonymous?
|
||||
|
||||
match = ForumTopicVisit.where(:user_id => user.id, :forum_topic_id => id).first
|
||||
if match
|
||||
|
@ -28,12 +28,6 @@
|
||||
</header>
|
||||
|
||||
<div id="page">
|
||||
<% if Danbooru.config.readonly_mode? %>
|
||||
<div id="readonly-notice" class="site-notice">
|
||||
<h1>The site is currently in readonly mode.</h1>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "news_updates/notice", news_update: NewsUpdate.recent %>
|
||||
|
||||
<% if CurrentUser.is_member? && (name_error = CurrentUser.name_error) %>
|
||||
|
@ -664,10 +664,6 @@ module Danbooru
|
||||
[]
|
||||
end
|
||||
|
||||
def readonly_mode?
|
||||
false
|
||||
end
|
||||
|
||||
def enable_visitor_metrics?
|
||||
false
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user