From 6cc523bd23528b6097d426f560a77b0316c3ac2a Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Thu, 2 Nov 2023 11:49:03 +0000 Subject: [PATCH] Correct email links to be absolute URLs --- lib/pleroma/emails/user_email.ex | 8 ++++---- test/pleroma/emails/user_email_test.exs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index fe319c775..a7bcc03b6 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -74,7 +74,7 @@ defmodule Pleroma.Emails.UserEmail do def password_reset_email(user, token) when is_binary(token) do Gettext.with_locale_or_default user.language do - password_reset_url = ~p[/api/v1/pleroma/password_reset/#{token}] + password_reset_url = url(~p[/api/v1/pleroma/password_reset/#{token}]) html_body = Gettext.dpgettext( @@ -107,7 +107,7 @@ defmodule Pleroma.Emails.UserEmail do to_name \\ nil ) do Gettext.with_locale_or_default user.language do - registration_url = ~p[/registration/#{user_invite_token.token}] + registration_url = url(~p[/registration/#{user_invite_token.token}]) html_body = Gettext.dpgettext( @@ -140,7 +140,7 @@ defmodule Pleroma.Emails.UserEmail do def account_confirmation_email(user) do Gettext.with_locale_or_default user.language do - confirmation_url = ~p[/api/account/confirm_email/#{user.id}/#{user.confirmation_token}] + confirmation_url = url(~p[/api/account/confirm_email/#{user.id}/#{user.confirmation_token}]) html_body = Gettext.dpgettext( @@ -330,7 +330,7 @@ defmodule Pleroma.Emails.UserEmail do |> Pleroma.JWT.generate_and_sign!() |> Base.encode64() - ~p[/mailer/unsubscribe/#{token}] + url(~p[/mailer/unsubscribe/#{token}]) end def backup_is_ready_email(backup, admin_user_id \\ nil) do diff --git a/test/pleroma/emails/user_email_test.exs b/test/pleroma/emails/user_email_test.exs index 259efbb65..ee76dc45c 100644 --- a/test/pleroma/emails/user_email_test.exs +++ b/test/pleroma/emails/user_email_test.exs @@ -16,7 +16,7 @@ defmodule Pleroma.Emails.UserEmailTest do assert email.from == {config[:name], config[:notify_email]} assert email.to == [{user.name, user.email}] assert email.subject == "Password reset" - assert email.html_body =~ ~p"/api/v1/pleroma/password_reset/test_token" + assert email.html_body =~ url(~p"/api/v1/pleroma/password_reset/test_token") end test "build user invitation email" do @@ -28,7 +28,7 @@ defmodule Pleroma.Emails.UserEmailTest do assert email.subject == "Invitation to Akkoma" assert email.to == [{"Jonh", "test@test.com"}] - assert email.html_body =~ ~p[/registration/#{token.token}] + assert email.html_body =~ url(~p[/registration/#{token.token}]) end test "build account confirmation email" do @@ -39,7 +39,7 @@ defmodule Pleroma.Emails.UserEmailTest do assert email.to == [{user.name, user.email}] assert email.subject == "#{config[:name]} account confirmation" - assert email.html_body =~ ~p[/account/confirm_email/#{user.id}/conf-token] + assert email.html_body =~ url(~p[/api/account/confirm_email/#{user.id}/conf-token]) end test "build approval pending email" do