Local copy of Pleroma, an ActivityPub server software. Contains modifications running live on fedi.underscore.world
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

subscription_controller.ex 673B

1234567891011121314151617181920
  1. defmodule Pleroma.Web.Mailer.SubscriptionController do
  2. use Pleroma.Web, :controller
  3. alias Pleroma.JWT
  4. alias Pleroma.Repo
  5. alias Pleroma.User
  6. def unsubscribe(conn, %{"token" => encoded_token}) do
  7. with {:ok, token} <- Base.decode64(encoded_token),
  8. {:ok, claims} <- JWT.verify_and_validate(token),
  9. %{"act" => %{"unsubscribe" => type}, "sub" => uid} <- claims,
  10. %User{} = user <- Repo.get(User, uid),
  11. {:ok, _user} <- User.switch_email_notifications(user, type, false) do
  12. render(conn, "unsubscribe_success.html", email: user.email)
  13. else
  14. _err ->
  15. render(conn, "unsubscribe_failure.html")
  16. end
  17. end
  18. end