Merge branch 'fix-email-headers' into 'master'
Fix email headers See merge request framasoft/mobilizon!912
This commit is contained in:
commit
4f8c698387
|
@ -8,7 +8,6 @@ defmodule Mobilizon.GraphQL.Resolvers.Member do
|
||||||
alias Mobilizon.Actors.{Actor, Member}
|
alias Mobilizon.Actors.{Actor, Member}
|
||||||
alias Mobilizon.Federation.ActivityPub
|
alias Mobilizon.Federation.ActivityPub
|
||||||
alias Mobilizon.Federation.ActivityPub.Actor, as: ActivityPubActor
|
alias Mobilizon.Federation.ActivityPub.Actor, as: ActivityPubActor
|
||||||
alias Mobilizon.Federation.ActivityPub.Refresher
|
|
||||||
alias Mobilizon.Storage.Page
|
alias Mobilizon.Storage.Page
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
import Mobilizon.Web.Gettext
|
import Mobilizon.Web.Gettext
|
||||||
|
@ -100,7 +99,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Member do
|
||||||
|
|
||||||
def accept_invitation(_parent, %{id: member_id}, %{context: %{current_user: %User{} = user}}) do
|
def accept_invitation(_parent, %{id: member_id}, %{context: %{current_user: %User{} = user}}) do
|
||||||
with %Actor{id: actor_id} <- Users.get_actor_for_user(user),
|
with %Actor{id: actor_id} <- Users.get_actor_for_user(user),
|
||||||
%Member{actor: %Actor{id: member_actor_id} = actor} = member <-
|
%Member{actor: %Actor{id: member_actor_id}} = member <-
|
||||||
Actors.get_member(member_id),
|
Actors.get_member(member_id),
|
||||||
{:is_same_actor, true} <- {:is_same_actor, member_actor_id === actor_id},
|
{:is_same_actor, true} <- {:is_same_actor, member_actor_id === actor_id},
|
||||||
{:ok, _activity, %Member{} = member} <-
|
{:ok, _activity, %Member{} = member} <-
|
||||||
|
|
|
@ -5,7 +5,6 @@ defmodule Mobilizon.Web.Email do
|
||||||
|
|
||||||
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
||||||
|
|
||||||
alias Ecto.UUID
|
|
||||||
alias Mobilizon.{Config, Events}
|
alias Mobilizon.{Config, Events}
|
||||||
alias Mobilizon.Events.Event
|
alias Mobilizon.Events.Event
|
||||||
alias Mobilizon.Service.Export.ICalendar
|
alias Mobilizon.Service.Export.ICalendar
|
||||||
|
@ -19,27 +18,27 @@ defmodule Mobilizon.Web.Email do
|
||||||
|> new_email()
|
|> new_email()
|
||||||
|> from({Config.instance_name(), Config.instance_email_from()})
|
|> from({Config.instance_name(), Config.instance_email_from()})
|
||||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||||
|> put_header("Date", date())
|
|> maybe_put_date_header()
|
||||||
|> put_header("Message-Id", message_id())
|
|> maybe_put_message_id()
|
||||||
|> assign(:instance, instance)
|
|> assign(:instance, instance)
|
||||||
|> put_html_layout({EmailView, "email.html"})
|
|> put_html_layout({EmailView, "email.html"})
|
||||||
|> put_text_layout({EmailView, "email.text"})
|
|> put_text_layout({EmailView, "email.text"})
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generating an UUID randomly causes Bamboo.Test.assert_delivered_email/1 to fail
|
# Generating an UUID randomly causes Bamboo.Test.assert_delivered_email/1 to fail
|
||||||
defp message_id do
|
defp maybe_put_message_id(email) do
|
||||||
if Application.fetch_env!(:mobilizon, :env) == :test do
|
if Application.fetch_env!(:mobilizon, :env) == :test do
|
||||||
"TEST_ENV_MESSAGE_ID@#{Config.instance_hostname()}"
|
put_header(email, "Message-Id", "TEST_ENV_MESSAGE_ID@#{Config.instance_hostname()}")
|
||||||
else
|
else
|
||||||
"#{UUID.generate()}@#{Config.instance_hostname()}"
|
email
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp date do
|
defp maybe_put_date_header(email) do
|
||||||
if Application.fetch_env!(:mobilizon, :env) == :test do
|
if Application.fetch_env!(:mobilizon, :env) == :test do
|
||||||
"REMOVED FOR TESTING"
|
put_header(email, "Date", "REMOVED FOR TESTING")
|
||||||
else
|
else
|
||||||
Timex.format!(DateTime.utc_now(), "{WDshort}, {D} {Mshort} {YYYY} {h24}:{m}:{s} {Z}")
|
email
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue