This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2023-06-12 14:22:46 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class MailSubscriptionsController < ApplicationController
|
|
|
|
layout 'auth'
|
|
|
|
|
|
|
|
skip_before_action :require_functional!
|
|
|
|
|
|
|
|
before_action :set_body_classes
|
|
|
|
before_action :set_user
|
|
|
|
before_action :set_type
|
|
|
|
|
2023-08-01 19:34:40 +02:00
|
|
|
protect_from_forgery with: :null_session
|
|
|
|
|
2023-06-12 14:22:46 +02:00
|
|
|
def show; end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@user.settings[email_type_from_param] = false
|
|
|
|
@user.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_user
|
|
|
|
@user = GlobalID::Locator.locate_signed(params[:token], for: 'unsubscribe')
|
2023-08-01 19:34:40 +02:00
|
|
|
not_found unless @user
|
2023-06-12 14:22:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_body_classes
|
|
|
|
@body_classes = 'lighter'
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_type
|
|
|
|
@type = email_type_from_param
|
|
|
|
end
|
|
|
|
|
|
|
|
def email_type_from_param
|
|
|
|
case params[:type]
|
|
|
|
when 'follow', 'reblog', 'favourite', 'mention', 'follow_request'
|
|
|
|
"notification_emails.#{params[:type]}"
|
|
|
|
else
|
2023-08-01 19:34:40 +02:00
|
|
|
not_found
|
2023-06-12 14:22:46 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|