Small fixes
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
6668a663a7
commit
cb4a801519
|
@ -621,6 +621,10 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||
Logger.info("Actor was deleted")
|
||||
{:error, :actor_deleted}
|
||||
|
||||
{:error, e} ->
|
||||
Logger.warn("Failed to make actor from url")
|
||||
{:error, e}
|
||||
|
||||
e ->
|
||||
Logger.warn("Failed to make actor from url")
|
||||
{:error, e}
|
||||
|
@ -801,6 +805,10 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||
Logger.info("Response HTTP 410")
|
||||
{:error, :actor_deleted}
|
||||
|
||||
{:error, e} ->
|
||||
Logger.warn("Could not decode actor at fetch #{url}, #{inspect(e)}")
|
||||
{:error, e}
|
||||
|
||||
e ->
|
||||
Logger.warn("Could not decode actor at fetch #{url}, #{inspect(e)}")
|
||||
{:error, e}
|
||||
|
|
|
@ -132,7 +132,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Discussions do
|
|||
)
|
||||
|
||||
args
|
||||
|> Map.update(:title, "", &String.trim/1)
|
||||
# title might be nil
|
||||
|> Map.update(:title, "", fn title -> String.trim(title || "") end)
|
||||
|> Map.put(:text, text)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -115,7 +115,7 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
|
|||
def create_user(_parent, args, _resolution) do
|
||||
with :registration_ok <- check_registration_config(args),
|
||||
{:ok, %User{} = user} <- Users.register(args),
|
||||
{:ok, %Bamboo.Email{}} <-
|
||||
%Bamboo.Email{} <-
|
||||
Email.User.send_confirmation_email(user, Map.get(args, :locale, "en")) do
|
||||
{:ok, user}
|
||||
else
|
||||
|
@ -206,7 +206,7 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
|
|||
Users.get_user_by_email(email, activated: true, unconfirmed: false),
|
||||
{:can_reset_password, true} <-
|
||||
{:can_reset_password, Authenticator.can_reset_password?(user)},
|
||||
{:ok, %Bamboo.Email{} = _email_html} <-
|
||||
{:ok, %Bamboo.Email{}} <-
|
||||
Email.User.send_password_reset_email(user, Map.get(args, :locale, locale)) do
|
||||
{:ok, email}
|
||||
else
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule Mobilizon do
|
|||
|
||||
alias Mobilizon.{Config, Storage, Web}
|
||||
alias Mobilizon.Federation.ActivityPub
|
||||
alias Mobilizon.Service.ErrorPage
|
||||
alias Mobilizon.Service.{ErrorPage, ErrorReporter}
|
||||
alias Mobilizon.Service.Export.{Feed, ICalendar}
|
||||
|
||||
@name Mix.Project.config()[:name]
|
||||
|
@ -68,6 +68,14 @@ defmodule Mobilizon do
|
|||
|
||||
Logger.add_backend(Sentry.LoggerBackend)
|
||||
:ok = Oban.Telemetry.attach_default_logger()
|
||||
|
||||
:telemetry.attach_many(
|
||||
"oban-errors",
|
||||
[[:oban, :job, :exception], [:oban, :circuit, :trip]],
|
||||
&ErrorReporter.handle_event/4,
|
||||
%{}
|
||||
)
|
||||
|
||||
Supervisor.start_link(children, strategy: :one_for_one, name: Mobilizon.Supervisor)
|
||||
end
|
||||
|
||||
|
|
17
lib/service/error_reporter.ex
Normal file
17
lib/service/error_reporter.ex
Normal file
|
@ -0,0 +1,17 @@
|
|||
defmodule Mobilizon.Service.ErrorReporter do
|
||||
@moduledoc """
|
||||
Module to delegate all exceptions to Sentry
|
||||
"""
|
||||
def handle_event([:oban, :job, :exception], measure, %{job: job} = meta, _) do
|
||||
extra =
|
||||
job
|
||||
|> Map.take([:id, :args, :meta, :queue, :worker])
|
||||
|> Map.merge(measure)
|
||||
|
||||
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: extra)
|
||||
end
|
||||
|
||||
def handle_event([:oban, :circuit, :trip], _measure, meta, _) do
|
||||
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: meta)
|
||||
end
|
||||
end
|
|
@ -5,7 +5,6 @@ defmodule Mobilizon.Web.Email.Mailer do
|
|||
use Bamboo.Mailer, otp_app: :mobilizon
|
||||
|
||||
def send_email_later(email) do
|
||||
try do
|
||||
Mobilizon.Web.Email.Mailer.deliver_later!(email)
|
||||
rescue
|
||||
error ->
|
||||
|
@ -16,10 +15,8 @@ defmodule Mobilizon.Web.Email.Mailer do
|
|||
|
||||
reraise error, __STACKTRACE__
|
||||
end
|
||||
end
|
||||
|
||||
def send_email(email) do
|
||||
try do
|
||||
Mobilizon.Web.Email.Mailer.deliver_now!(email)
|
||||
rescue
|
||||
error ->
|
||||
|
@ -30,5 +27,4 @@ defmodule Mobilizon.Web.Email.Mailer do
|
|||
|
||||
reraise error, __STACKTRACE__
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,7 +80,7 @@ defmodule Mobilizon.Web.Email.User do
|
|||
Users.update_user(user, %{
|
||||
"confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
}),
|
||||
{:ok, %Bamboo.Email{}} <- send_confirmation_email(user, locale) do
|
||||
%Bamboo.Email{} <- send_confirmation_email(user, locale) do
|
||||
Logger.info("Sent confirmation email again to #{user.email}")
|
||||
{:ok, user.email}
|
||||
end
|
||||
|
@ -132,7 +132,7 @@ defmodule Mobilizon.Web.Email.User do
|
|||
"reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
})
|
||||
),
|
||||
{:ok, %Bamboo.Email{} = mail} <-
|
||||
%Bamboo.Email{} = mail <-
|
||||
user_updated
|
||||
|> Email.User.reset_password_email(locale)
|
||||
|> Email.Mailer.send_email_later() do
|
||||
|
|
Loading…
Reference in a new issue