From 9a65b29640824c6f4be382926608c280315b7be2 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Apr 2021 14:47:19 +0200 Subject: [PATCH 1/6] Rename "Close events" to "Nearby events" Closes #662 Signed-off-by: Thomas Citharel --- js/src/i18n/ca.json | 2 +- js/src/i18n/de.json | 2 +- js/src/i18n/en_US.json | 2 +- js/src/i18n/es.json | 2 +- js/src/i18n/fr_FR.json | 2 +- js/src/i18n/gd.json | 2 +- js/src/i18n/gl.json | 2 +- js/src/i18n/hu.json | 2 +- js/src/i18n/nn.json | 2 +- js/src/i18n/ru.json | 2 +- js/src/i18n/sl.json | 2 +- js/src/views/Home.vue | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/js/src/i18n/ca.json b/js/src/i18n/ca.json index a8b9e26d7..a280aa4bb 100644 --- a/js/src/i18n/ca.json +++ b/js/src/i18n/ca.json @@ -132,7 +132,7 @@ "Click to upload": "Clica per pujar", "Close": "Deshabilita", "Close comments for all (except for admins)": "Deshabilita els comentaris per a tothom excepte admins", - "Close events": "Activitats prop de tu", + "Events nearby": "Activitats prop de tu", "Closed": "Deshabilitats", "Comment deleted": "S'ha esborrat el comentari", "Comment from @{username} reported": "S'ha denunciat un comentari de @{username}", diff --git a/js/src/i18n/de.json b/js/src/i18n/de.json index 9b5306544..b0147437e 100644 --- a/js/src/i18n/de.json +++ b/js/src/i18n/de.json @@ -135,7 +135,7 @@ "Click to upload": "Klicken zum Hochladen", "Close": "Schließen", "Close comments for all (except for admins)": "Kommentare für alle sperren (außer für Admins)", - "Close events": "Veranstaltungen in Ihrer Nähe", + "Events nearby": "Veranstaltungen in Ihrer Nähe", "Closed": "Geschlossen", "Comment deleted": "Kommentar gelöscht", "Comment from @{username} reported": "Kommentar von @{username} gemeldet", diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index 7498744f6..cffa26a7d 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -858,7 +858,7 @@ "Your upcoming events": "Your upcoming events", "Last published events": "Last published events", "On {instance}": "On {instance}", - "Close events": "Close events", + "Events nearby": "Events nearby", "Within {number} kilometers of {place}": "|Within one kilometer of {place}|Within {number} kilometers of {place}", "@{username}": "@{username}", "Yesterday": "Yesterday", diff --git a/js/src/i18n/es.json b/js/src/i18n/es.json index df4a2d1dd..e4fbc565b 100644 --- a/js/src/i18n/es.json +++ b/js/src/i18n/es.json @@ -138,7 +138,7 @@ "Click to upload": "Haz clic para subir (upload)", "Close": "Cerrar", "Close comments for all (except for admins)": "Cerrar comentarios para todos (excepto para administradores)", - "Close events": "Eventos cercanos", + "Events nearby": "Eventos cercanos", "Closed": "Cerrado", "Collections": "Colecciones", "Comment deleted": "Comentario borrado", diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index 64f62c690..1866b0f3a 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -128,7 +128,7 @@ "Click to upload": "Cliquez pour téléverser", "Close": "Fermé", "Close comments for all (except for admins)": "Fermer les commentaires à tout le monde (excepté les administrateur⋅rice·s)", - "Close events": "Événements proches", + "Events nearby": "Événements proches", "Closed": "Fermé", "Comment deleted": "Commentaire supprimé", "Comment from @{username} reported": "Commentaire de @{username} signalé", diff --git a/js/src/i18n/gd.json b/js/src/i18n/gd.json index 90dab0983..b22b1f1d5 100644 --- a/js/src/i18n/gd.json +++ b/js/src/i18n/gd.json @@ -122,7 +122,7 @@ "Click to upload": "Briog airson luchdadh suas", "Close": "Dùin", "Close comments for all (except for admins)": "Dùin na beachdan dhan a h-uile duine (ach rianairean)", - "Close events": "Tachartasan am fagas", + "Events nearby": "Tachartasan am fagas", "Closed": "Dùinte", "Comment deleted": "Chaidh am beachd a sguabadh às", "Comment from @{username} reported": "Chaidh gearan a dhèanamh mu bheachd le @{username}", diff --git a/js/src/i18n/gl.json b/js/src/i18n/gl.json index d994ec988..08a906dbb 100644 --- a/js/src/i18n/gl.json +++ b/js/src/i18n/gl.json @@ -131,7 +131,7 @@ "Click to upload": "Preme para subir", "Close": "Pechar", "Close comments for all (except for admins)": "Pechar comentarios para todos (excepto admins)", - "Close events": "Pechar eventos", + "Events nearby": "Pechar eventos", "Closed": "Pechado", "Comment deleted": "Comentario eliminado", "Comment from @{username} reported": "Comentario de @{username} denunciado", diff --git a/js/src/i18n/hu.json b/js/src/i18n/hu.json index 28c5ed299..3c05a810c 100644 --- a/js/src/i18n/hu.json +++ b/js/src/i18n/hu.json @@ -127,7 +127,7 @@ "Click to upload": "Kattintson a feltöltéshez", "Close": "Lezárás", "Close comments for all (except for admins)": "Hozzászólások lezárása mindenkinél (kivéve az adminisztrátoroknál)", - "Close events": "Események bezárása", + "Events nearby": "Események bezárása", "Closed": "Lezárva", "Comment deleted": "Hozzászólás törölve", "Comment from @{username} reported": "@{username} felhasználótól érkezett hozzászólás jelentve", diff --git a/js/src/i18n/nn.json b/js/src/i18n/nn.json index 153689497..613e582bf 100644 --- a/js/src/i18n/nn.json +++ b/js/src/i18n/nn.json @@ -127,7 +127,7 @@ "Click to upload": "Klikk for å lasta opp", "Close": "Steng", "Close comments for all (except for admins)": "Steng for kommentarar frå alle (unnateke administratorar)", - "Close events": "Hendingar i nærleiken", + "Events nearby": "Hendingar i nærleiken", "Closed": "Stengt", "Comment deleted": "Kommentaren er sletta", "Comment from @{username} reported": "Kommentaren frå @{username} er rapportert", diff --git a/js/src/i18n/ru.json b/js/src/i18n/ru.json index 9e67eccab..12ffa3d90 100644 --- a/js/src/i18n/ru.json +++ b/js/src/i18n/ru.json @@ -122,7 +122,7 @@ "Click to upload": "Нажмите, чтобы загрузить", "Close": "Закрыть", "Close comments for all (except for admins)": "Закрыть комментарии для всех (кроме админов)", - "Close events": "Ближайшие мероприятия", + "Events nearby": "Ближайшие мероприятия", "Closed": "Закрыто", "Comment deleted": "Комментарий удален", "Comment from @{username} reported": "Жалоба на комментарий от @{username} отправлена", diff --git a/js/src/i18n/sl.json b/js/src/i18n/sl.json index 3ab97fd3d..ff91e5c1d 100644 --- a/js/src/i18n/sl.json +++ b/js/src/i18n/sl.json @@ -123,7 +123,7 @@ "Click to upload": "Kliknite za pošiljanje", "Close": "Zapri", "Close comments for all (except for admins)": "Zapri komentarje za vse (razen za skrbnike)", - "Close events": "Zapri dogodke", + "Events nearby": "Zapri dogodke", "Closed": "Zaprto", "Comment deleted": "Komentar je izbrisan", "Comment from @{username} reported": "Prijavljen je bil komentar uporabnika @{username}", diff --git a/js/src/views/Home.vue b/js/src/views/Home.vue index 0b86d4ac4..a8b7990ba 100644 --- a/js/src/views/Home.vue +++ b/js/src/views/Home.vue @@ -252,7 +252,7 @@

- {{ $t("Close events") }} + {{ $t("Events nearby") }}

{{ From d98e68203e8323f68c59da42de99bc5e2f6dc09c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Apr 2021 15:02:24 +0200 Subject: [PATCH 2/6] Handle sending mail more properly With custom sentry reporting issues Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/activity_pub.ex | 2 +- lib/graphql/resolvers/participant.ex | 2 +- lib/graphql/resolvers/user.ex | 4 +-- lib/service/workers/notification.ex | 8 +++--- lib/web/email/event.ex | 2 +- lib/web/email/follow.ex | 2 +- lib/web/email/group.ex | 8 +++--- lib/web/email/mailer.ex | 28 +++++++++++++++++++++ lib/web/email/participation.ex | 4 +-- lib/web/email/user.ex | 4 +-- 10 files changed, 46 insertions(+), 18 deletions(-) diff --git a/lib/federation/activity_pub/activity_pub.ex b/lib/federation/activity_pub/activity_pub.ex index 608955b0b..483f7c7d2 100644 --- a/lib/federation/activity_pub/activity_pub.ex +++ b/lib/federation/activity_pub/activity_pub.ex @@ -592,7 +592,7 @@ defmodule Mobilizon.Federation.ActivityPub do Enum.each(Users.list_moderators(), fn moderator -> moderator |> Admin.report(report) - |> Mailer.deliver_later() + |> Mailer.send_email_later() end) {:ok, activity, report} diff --git a/lib/graphql/resolvers/participant.ex b/lib/graphql/resolvers/participant.ex index ede77f0dd..6b20a3641 100644 --- a/lib/graphql/resolvers/participant.ex +++ b/lib/graphql/resolvers/participant.ex @@ -70,7 +70,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do participant, Map.get(args, :locale, "en") ) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() end {:ok, participant} diff --git a/lib/graphql/resolvers/user.ex b/lib/graphql/resolvers/user.ex index a07da0074..467305b9d 100644 --- a/lib/graphql/resolvers/user.ex +++ b/lib/graphql/resolvers/user.ex @@ -358,11 +358,11 @@ defmodule Mobilizon.GraphQL.Resolvers.User do {:ok, %User{} = user} <- Users.update_user_email(user, new_email) do user |> Email.User.send_email_reset_old_email() - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() user |> Email.User.send_email_reset_new_email() - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() {:ok, user} else diff --git a/lib/service/workers/notification.ex b/lib/service/workers/notification.ex index a3a7ff9a9..19202f8b2 100644 --- a/lib/service/workers/notification.ex +++ b/lib/service/workers/notification.ex @@ -23,7 +23,7 @@ defmodule Mobilizon.Service.Workers.Notification do Users.get_user_with_settings!(user_id) do email |> Notification.before_event_notification(participant, locale) - |> Mailer.deliver_later() + |> Mailer.send_email_later() :ok end @@ -48,7 +48,7 @@ defmodule Mobilizon.Service.Workers.Notification do true <- length(participations) > 0 do user |> Notification.on_day_notification(participations, total, locale) - |> Mailer.deliver_later() + |> Mailer.send_email_later() :ok else @@ -77,7 +77,7 @@ defmodule Mobilizon.Service.Workers.Notification do true <- length(participations) > 0 do user |> Notification.weekly_notification(participations, total, locale) - |> Mailer.deliver_later() + |> Mailer.send_email_later() :ok else @@ -99,7 +99,7 @@ defmodule Mobilizon.Service.Workers.Notification do Events.list_participants_for_event(event_id, [:not_approved]) do user |> Notification.pending_participation_notification(event, total) - |> Mailer.deliver_later() + |> Mailer.send_email_later() :ok else diff --git a/lib/web/email/event.ex b/lib/web/email/event.ex index 2a34fb347..5b3e39ddc 100644 --- a/lib/web/email/event.ex +++ b/lib/web/email/event.ex @@ -143,6 +143,6 @@ defmodule Mobilizon.Web.Email.Event do ) do email |> Email.Event.event_updated(actor, old_event, event, diff, timezone, locale) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() end end diff --git a/lib/web/email/follow.ex b/lib/web/email/follow.ex index ef12e495f..25c3c953d 100644 --- a/lib/web/email/follow.ex +++ b/lib/web/email/follow.ex @@ -62,7 +62,7 @@ defmodule Mobilizon.Web.Email.Follow do |> assign(:follower, follower) |> assign(:subject, subject) |> render(:instance_follow) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() :ok end diff --git a/lib/web/email/group.ex b/lib/web/email/group.ex index 440c0f20b..2c3029007 100644 --- a/lib/web/email/group.ex +++ b/lib/web/email/group.ex @@ -42,7 +42,7 @@ defmodule Mobilizon.Web.Email.Group do |> assign(:group, group) |> assign(:subject, subject) |> render(:group_invite) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() :ok end @@ -70,7 +70,7 @@ defmodule Mobilizon.Web.Email.Group do |> assign(:group, group) |> assign(:subject, subject) |> render(:group_member_removal) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() :ok end @@ -107,7 +107,7 @@ defmodule Mobilizon.Web.Email.Group do |> assign(:subject, subject) |> assign(:instance, instance) |> render(:group_suspension) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() :ok end @@ -147,7 +147,7 @@ defmodule Mobilizon.Web.Email.Group do |> assign(:instance, instance) |> assign(:author, author) |> render(:group_deletion) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() :ok else diff --git a/lib/web/email/mailer.ex b/lib/web/email/mailer.ex index 87316f1ce..3b286834c 100644 --- a/lib/web/email/mailer.ex +++ b/lib/web/email/mailer.ex @@ -3,4 +3,32 @@ defmodule Mobilizon.Web.Email.Mailer do Mobilizon Mailer. """ use Bamboo.Mailer, otp_app: :mobilizon + + def send_email_later(email) do + try do + Mobilizon.Web.Email.Mailer.deliver_later!(email) + rescue + error -> + Sentry.capture_exception(error, + stacktrace: __STACKTRACE__, + extra: %{extra: "Error while sending email"} + ) + + reraise error, __STACKTRACE__ + end + end + + def send_email(email) do + try do + Mobilizon.Web.Email.Mailer.deliver_now!(email) + rescue + error -> + Sentry.capture_exception(error, + stacktrace: __STACKTRACE__, + extra: %{extra: "Error while sending email"} + ) + + reraise error, __STACKTRACE__ + end + end end diff --git a/lib/web/email/participation.ex b/lib/web/email/participation.ex index 132c0d8a2..dbd90e694 100644 --- a/lib/web/email/participation.ex +++ b/lib/web/email/participation.ex @@ -28,7 +28,7 @@ defmodule Mobilizon.Web.Email.Participation do email |> participation_updated(participation, locale) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() end :ok @@ -40,7 +40,7 @@ defmodule Mobilizon.Web.Email.Participation do with %User{locale: locale} = user <- Users.get_user!(user_id) do user |> participation_updated(participation, locale) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() :ok end diff --git a/lib/web/email/user.ex b/lib/web/email/user.ex index 01d315434..5f45d3e24 100644 --- a/lib/web/email/user.ex +++ b/lib/web/email/user.ex @@ -90,7 +90,7 @@ defmodule Mobilizon.Web.Email.User do def send_confirmation_email(%User{} = user, locale \\ "en") do user |> Email.User.confirmation_email(locale) - |> Email.Mailer.deliver_later() + |> Email.Mailer.send_email_later() end @doc """ @@ -135,7 +135,7 @@ defmodule Mobilizon.Web.Email.User do {:ok, %Bamboo.Email{} = mail} <- user_updated |> Email.User.reset_password_email(locale) - |> Email.Mailer.deliver_later() do + |> Email.Mailer.send_email_later() do {:ok, mail} else {:error, reason} -> {:error, reason} From 118175db3eca600b3598862ec9c0c37ec821deea Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Apr 2021 15:07:38 +0200 Subject: [PATCH 3/6] Link Sentry to telemetry Signed-off-by: Thomas Citharel --- lib/mobilizon.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mobilizon.ex b/lib/mobilizon.ex index a1ca09962..d07059dd8 100644 --- a/lib/mobilizon.ex +++ b/lib/mobilizon.ex @@ -66,6 +66,8 @@ defmodule Mobilizon do ] ++ task_children(@env) + Logger.add_backend(Sentry.LoggerBackend) + :ok = Oban.Telemetry.attach_default_logger() Supervisor.start_link(children, strategy: :one_for_one, name: Mobilizon.Supervisor) end From 6668a663a78511bb459676ead6b70709d686721d Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Apr 2021 15:07:57 +0200 Subject: [PATCH 4/6] Add user context to Sentry Signed-off-by: Thomas Citharel --- lib/web/auth/context.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/web/auth/context.ex b/lib/web/auth/context.ex index 9f41dd61f..aaa16e25a 100644 --- a/lib/web/auth/context.ex +++ b/lib/web/auth/context.ex @@ -23,7 +23,8 @@ defmodule Mobilizon.Web.Auth.Context do context = case Guardian.Plug.current_resource(conn) do - %User{} = user -> + %User{id: user_id, email: user_email} = user -> + Sentry.Context.set_user_context(%{id: user_id, name: user_email}) Map.put(context, :current_user, user) nil -> From cb4a8015199aa4e7b0767e69adcd1fa875fd820e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Apr 2021 15:27:33 +0200 Subject: [PATCH 5/6] Small fixes Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/activity_pub.ex | 8 +++++ .../activity_pub/types/discussions.ex | 3 +- lib/graphql/resolvers/user.ex | 4 +-- lib/mobilizon.ex | 10 +++++- lib/service/error_reporter.ex | 17 +++++++++ lib/web/email/mailer.ex | 36 +++++++++---------- lib/web/email/user.ex | 4 +-- 7 files changed, 56 insertions(+), 26 deletions(-) create mode 100644 lib/service/error_reporter.ex diff --git a/lib/federation/activity_pub/activity_pub.ex b/lib/federation/activity_pub/activity_pub.ex index 483f7c7d2..824b9c3c5 100644 --- a/lib/federation/activity_pub/activity_pub.ex +++ b/lib/federation/activity_pub/activity_pub.ex @@ -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} diff --git a/lib/federation/activity_pub/types/discussions.ex b/lib/federation/activity_pub/types/discussions.ex index f9b615d68..3f06baed1 100644 --- a/lib/federation/activity_pub/types/discussions.ex +++ b/lib/federation/activity_pub/types/discussions.ex @@ -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 diff --git a/lib/graphql/resolvers/user.ex b/lib/graphql/resolvers/user.ex index 467305b9d..82a4dde34 100644 --- a/lib/graphql/resolvers/user.ex +++ b/lib/graphql/resolvers/user.ex @@ -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 diff --git a/lib/mobilizon.ex b/lib/mobilizon.ex index d07059dd8..c754964ac 100644 --- a/lib/mobilizon.ex +++ b/lib/mobilizon.ex @@ -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 diff --git a/lib/service/error_reporter.ex b/lib/service/error_reporter.ex new file mode 100644 index 000000000..46900d945 --- /dev/null +++ b/lib/service/error_reporter.ex @@ -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 diff --git a/lib/web/email/mailer.ex b/lib/web/email/mailer.ex index 3b286834c..4996f7696 100644 --- a/lib/web/email/mailer.ex +++ b/lib/web/email/mailer.ex @@ -5,30 +5,26 @@ 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 -> - Sentry.capture_exception(error, - stacktrace: __STACKTRACE__, - extra: %{extra: "Error while sending email"} - ) + Mobilizon.Web.Email.Mailer.deliver_later!(email) + rescue + error -> + Sentry.capture_exception(error, + stacktrace: __STACKTRACE__, + extra: %{extra: "Error while sending email"} + ) - reraise error, __STACKTRACE__ - end + reraise error, __STACKTRACE__ end def send_email(email) do - try do - Mobilizon.Web.Email.Mailer.deliver_now!(email) - rescue - error -> - Sentry.capture_exception(error, - stacktrace: __STACKTRACE__, - extra: %{extra: "Error while sending email"} - ) + Mobilizon.Web.Email.Mailer.deliver_now!(email) + rescue + error -> + Sentry.capture_exception(error, + stacktrace: __STACKTRACE__, + extra: %{extra: "Error while sending email"} + ) - reraise error, __STACKTRACE__ - end + reraise error, __STACKTRACE__ end end diff --git a/lib/web/email/user.ex b/lib/web/email/user.ex index 5f45d3e24..7dd74b70b 100644 --- a/lib/web/email/user.ex +++ b/lib/web/email/user.ex @@ -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 From 6ad4e33fabf4606f8a32da9cab70430a1deee65c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Apr 2021 16:55:55 +0200 Subject: [PATCH 6/6] Suspended actors don't need refreshing Signed-off-by: Thomas Citharel --- lib/mobilizon/actors/actors.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mobilizon/actors/actors.ex b/lib/mobilizon/actors/actors.ex index 21dc47a8b..aabdf21ef 100644 --- a/lib/mobilizon/actors/actors.ex +++ b/lib/mobilizon/actors/actors.ex @@ -1282,11 +1282,13 @@ defmodule Mobilizon.Actors do @doc """ Whether the actor needs to be updated. - Local actors obviously don't need to be updated + Local actors obviously don't need to be updated, neither do suspended ones """ @spec needs_update?(Actor.t()) :: boolean def needs_update?(%Actor{domain: nil}), do: false + def needs_update?(%Actor{suspended: true}), do: false + def needs_update?(%Actor{last_refreshed_at: nil, domain: domain}) when not is_nil(domain), do: true