Correct email links to be absolute URLs

This commit is contained in:
FloatingGhost 2023-11-02 11:49:03 +00:00
parent fb700a956a
commit 6cc523bd23
2 changed files with 7 additions and 7 deletions

View file

@ -74,7 +74,7 @@ defmodule Pleroma.Emails.UserEmail do
def password_reset_email(user, token) when is_binary(token) do def password_reset_email(user, token) when is_binary(token) do
Gettext.with_locale_or_default user.language 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 = html_body =
Gettext.dpgettext( Gettext.dpgettext(
@ -107,7 +107,7 @@ defmodule Pleroma.Emails.UserEmail do
to_name \\ nil to_name \\ nil
) do ) do
Gettext.with_locale_or_default user.language 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 = html_body =
Gettext.dpgettext( Gettext.dpgettext(
@ -140,7 +140,7 @@ defmodule Pleroma.Emails.UserEmail do
def account_confirmation_email(user) do def account_confirmation_email(user) do
Gettext.with_locale_or_default user.language 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 = html_body =
Gettext.dpgettext( Gettext.dpgettext(
@ -330,7 +330,7 @@ defmodule Pleroma.Emails.UserEmail do
|> Pleroma.JWT.generate_and_sign!() |> Pleroma.JWT.generate_and_sign!()
|> Base.encode64() |> Base.encode64()
~p[/mailer/unsubscribe/#{token}] url(~p[/mailer/unsubscribe/#{token}])
end end
def backup_is_ready_email(backup, admin_user_id \\ nil) do def backup_is_ready_email(backup, admin_user_id \\ nil) do

View file

@ -16,7 +16,7 @@ defmodule Pleroma.Emails.UserEmailTest do
assert email.from == {config[:name], config[:notify_email]} assert email.from == {config[:name], config[:notify_email]}
assert email.to == [{user.name, user.email}] assert email.to == [{user.name, user.email}]
assert email.subject == "Password reset" 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 end
test "build user invitation email" do test "build user invitation email" do
@ -28,7 +28,7 @@ defmodule Pleroma.Emails.UserEmailTest do
assert email.subject == "Invitation to Akkoma" assert email.subject == "Invitation to Akkoma"
assert email.to == [{"Jonh", "test@test.com"}] 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 end
test "build account confirmation email" do test "build account confirmation email" do
@ -39,7 +39,7 @@ defmodule Pleroma.Emails.UserEmailTest do
assert email.to == [{user.name, user.email}] assert email.to == [{user.name, user.email}]
assert email.subject == "#{config[:name]} account confirmation" 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 end
test "build approval pending email" do test "build approval pending email" do