mastodon/app/controllers/admin/email_subscriptions/setups_controller.rb
Eugen Rochko ee88da4511
Add admin UI for managing email subscriptions (#38741)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2026-05-04 13:56:04 +00:00

35 lines
840 B
Ruby

# frozen_string_literal: true
class Admin::EmailSubscriptions::SetupsController < Admin::BaseController
before_action :require_enabled!
def show
authorize :email_subscription, :enable?
@form = Form::EmailSubscriptionsConfirmation.new
end
def create
authorize :email_subscription, :enable?
@form = Form::EmailSubscriptionsConfirmation.new(resource_params)
if @form.valid?
Setting.email_subscriptions = true
redirect_to admin_email_subscriptions_path
else
render :show
end
end
private
def require_enabled!
raise ActionController::RoutingError, 'Feature disabled' unless Rails.application.config.x.email_subscriptions
end
def resource_params
params.expect(form_email_subscriptions_confirmation: [:agreement_email_volume, :agreement_privacy_and_terms])
end
end