mirror of https://github.com/mastodon/mastodon
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
787 B
Ruby
42 lines
787 B
Ruby
2 years ago
|
# 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
|
||
|
|
||
|
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')
|
||
|
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
|
||
|
raise ArgumentError
|
||
|
end
|
||
|
end
|
||
|
end
|