1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Mailer.SubscriptionController do
6 use Pleroma.Web, :controller
12 def unsubscribe(conn, %{"token" => encoded_token}) do
13 with {:ok, token} <- Base.decode64(encoded_token),
14 {:ok, claims} <- JWT.verify_and_validate(token),
15 %{"act" => %{"unsubscribe" => type}, "sub" => uid} <- claims,
16 %User{} = user <- Repo.get(User, uid),
17 {:ok, _user} <- User.switch_email_notifications(user, type, false) do
18 render(conn, "unsubscribe_success.html", email: user.email)
21 render(conn, "unsubscribe_failure.html")