Merge branch 'fixes' into 'master'

Rename "Close events" to "Nearby events"

Closes #662

See merge request framasoft/mobilizon!900
This commit is contained in:
Thomas Citharel 2021-04-20 15:42:22 +00:00
commit b371a9fe01
27 changed files with 101 additions and 38 deletions

View File

@ -132,7 +132,7 @@
"Click to upload": "Clica per pujar", "Click to upload": "Clica per pujar",
"Close": "Deshabilita", "Close": "Deshabilita",
"Close comments for all (except for admins)": "Deshabilita els comentaris per a tothom excepte admins", "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", "Closed": "Deshabilitats",
"Comment deleted": "S'ha esborrat el comentari", "Comment deleted": "S'ha esborrat el comentari",
"Comment from @{username} reported": "S'ha denunciat un comentari de @{username}", "Comment from @{username} reported": "S'ha denunciat un comentari de @{username}",

View File

@ -135,7 +135,7 @@
"Click to upload": "Klicken zum Hochladen", "Click to upload": "Klicken zum Hochladen",
"Close": "Schließen", "Close": "Schließen",
"Close comments for all (except for admins)": "Kommentare für alle sperren (außer für Admins)", "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", "Closed": "Geschlossen",
"Comment deleted": "Kommentar gelöscht", "Comment deleted": "Kommentar gelöscht",
"Comment from @{username} reported": "Kommentar von @{username} gemeldet", "Comment from @{username} reported": "Kommentar von @{username} gemeldet",

View File

@ -858,7 +858,7 @@
"Your upcoming events": "Your upcoming events", "Your upcoming events": "Your upcoming events",
"Last published events": "Last published events", "Last published events": "Last published events",
"On {instance}": "On {instance}", "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}", "Within {number} kilometers of {place}": "|Within one kilometer of {place}|Within {number} kilometers of {place}",
"@{username}": "@{username}", "@{username}": "@{username}",
"Yesterday": "Yesterday", "Yesterday": "Yesterday",

View File

@ -138,7 +138,7 @@
"Click to upload": "Haz clic para subir (upload)", "Click to upload": "Haz clic para subir (upload)",
"Close": "Cerrar", "Close": "Cerrar",
"Close comments for all (except for admins)": "Cerrar comentarios para todos (excepto para administradores)", "Close comments for all (except for admins)": "Cerrar comentarios para todos (excepto para administradores)",
"Close events": "Eventos cercanos", "Events nearby": "Eventos cercanos",
"Closed": "Cerrado", "Closed": "Cerrado",
"Collections": "Colecciones", "Collections": "Colecciones",
"Comment deleted": "Comentario borrado", "Comment deleted": "Comentario borrado",

View File

@ -128,7 +128,7 @@
"Click to upload": "Cliquez pour téléverser", "Click to upload": "Cliquez pour téléverser",
"Close": "Fermé", "Close": "Fermé",
"Close comments for all (except for admins)": "Fermer les commentaires à tout le monde (excepté les administrateur⋅rice·s)", "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é", "Closed": "Fermé",
"Comment deleted": "Commentaire supprimé", "Comment deleted": "Commentaire supprimé",
"Comment from @{username} reported": "Commentaire de @{username} signalé", "Comment from @{username} reported": "Commentaire de @{username} signalé",

View File

@ -122,7 +122,7 @@
"Click to upload": "Briog airson luchdadh suas", "Click to upload": "Briog airson luchdadh suas",
"Close": "Dùin", "Close": "Dùin",
"Close comments for all (except for admins)": "Dùin na beachdan dhan a h-uile duine (ach rianairean)", "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", "Closed": "Dùinte",
"Comment deleted": "Chaidh am beachd a sguabadh às", "Comment deleted": "Chaidh am beachd a sguabadh às",
"Comment from @{username} reported": "Chaidh gearan a dhèanamh mu bheachd le @{username}", "Comment from @{username} reported": "Chaidh gearan a dhèanamh mu bheachd le @{username}",

View File

@ -131,7 +131,7 @@
"Click to upload": "Preme para subir", "Click to upload": "Preme para subir",
"Close": "Pechar", "Close": "Pechar",
"Close comments for all (except for admins)": "Pechar comentarios para todos (excepto admins)", "Close comments for all (except for admins)": "Pechar comentarios para todos (excepto admins)",
"Close events": "Pechar eventos", "Events nearby": "Pechar eventos",
"Closed": "Pechado", "Closed": "Pechado",
"Comment deleted": "Comentario eliminado", "Comment deleted": "Comentario eliminado",
"Comment from @{username} reported": "Comentario de @{username} denunciado", "Comment from @{username} reported": "Comentario de @{username} denunciado",

View File

@ -127,7 +127,7 @@
"Click to upload": "Kattintson a feltöltéshez", "Click to upload": "Kattintson a feltöltéshez",
"Close": "Lezárás", "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 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", "Closed": "Lezárva",
"Comment deleted": "Hozzászólás törölve", "Comment deleted": "Hozzászólás törölve",
"Comment from @{username} reported": "@{username} felhasználótól érkezett hozzászólás jelentve", "Comment from @{username} reported": "@{username} felhasználótól érkezett hozzászólás jelentve",

View File

@ -127,7 +127,7 @@
"Click to upload": "Klikk for å lasta opp", "Click to upload": "Klikk for å lasta opp",
"Close": "Steng", "Close": "Steng",
"Close comments for all (except for admins)": "Steng for kommentarar frå alle (unnateke administratorar)", "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", "Closed": "Stengt",
"Comment deleted": "Kommentaren er sletta", "Comment deleted": "Kommentaren er sletta",
"Comment from @{username} reported": "Kommentaren frå @{username} er rapportert", "Comment from @{username} reported": "Kommentaren frå @{username} er rapportert",

View File

@ -122,7 +122,7 @@
"Click to upload": "Нажмите, чтобы загрузить", "Click to upload": "Нажмите, чтобы загрузить",
"Close": "Закрыть", "Close": "Закрыть",
"Close comments for all (except for admins)": "Закрыть комментарии для всех (кроме админов)", "Close comments for all (except for admins)": "Закрыть комментарии для всех (кроме админов)",
"Close events": "Ближайшие мероприятия", "Events nearby": "Ближайшие мероприятия",
"Closed": "Закрыто", "Closed": "Закрыто",
"Comment deleted": "Комментарий удален", "Comment deleted": "Комментарий удален",
"Comment from @{username} reported": "Жалоба на комментарий от @{username} отправлена", "Comment from @{username} reported": "Жалоба на комментарий от @{username} отправлена",

View File

@ -123,7 +123,7 @@
"Click to upload": "Kliknite za pošiljanje", "Click to upload": "Kliknite za pošiljanje",
"Close": "Zapri", "Close": "Zapri",
"Close comments for all (except for admins)": "Zapri komentarje za vse (razen za skrbnike)", "Close comments for all (except for admins)": "Zapri komentarje za vse (razen za skrbnike)",
"Close events": "Zapri dogodke", "Events nearby": "Zapri dogodke",
"Closed": "Zaprto", "Closed": "Zaprto",
"Comment deleted": "Komentar je izbrisan", "Comment deleted": "Komentar je izbrisan",
"Comment from @{username} reported": "Prijavljen je bil komentar uporabnika @{username}", "Comment from @{username} reported": "Prijavljen je bil komentar uporabnika @{username}",

View File

@ -252,7 +252,7 @@
<!-- Events close to you --> <!-- Events close to you -->
<section class="events-close" v-if="closeEvents.total > 0"> <section class="events-close" v-if="closeEvents.total > 0">
<h2 class="is-size-2 has-text-weight-bold"> <h2 class="is-size-2 has-text-weight-bold">
{{ $t("Close events") }} {{ $t("Events nearby") }}
</h2> </h2>
<p> <p>
{{ {{

View File

@ -592,7 +592,7 @@ defmodule Mobilizon.Federation.ActivityPub do
Enum.each(Users.list_moderators(), fn moderator -> Enum.each(Users.list_moderators(), fn moderator ->
moderator moderator
|> Admin.report(report) |> Admin.report(report)
|> Mailer.deliver_later() |> Mailer.send_email_later()
end) end)
{:ok, activity, report} {:ok, activity, report}
@ -621,6 +621,10 @@ defmodule Mobilizon.Federation.ActivityPub do
Logger.info("Actor was deleted") Logger.info("Actor was deleted")
{:error, :actor_deleted} {:error, :actor_deleted}
{:error, e} ->
Logger.warn("Failed to make actor from url")
{:error, e}
e -> e ->
Logger.warn("Failed to make actor from url") Logger.warn("Failed to make actor from url")
{:error, e} {:error, e}
@ -801,6 +805,10 @@ defmodule Mobilizon.Federation.ActivityPub do
Logger.info("Response HTTP 410") Logger.info("Response HTTP 410")
{:error, :actor_deleted} {:error, :actor_deleted}
{:error, e} ->
Logger.warn("Could not decode actor at fetch #{url}, #{inspect(e)}")
{:error, e}
e -> e ->
Logger.warn("Could not decode actor at fetch #{url}, #{inspect(e)}") Logger.warn("Could not decode actor at fetch #{url}, #{inspect(e)}")
{:error, e} {:error, e}

View File

@ -132,7 +132,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Discussions do
) )
args args
|> Map.update(:title, "", &String.trim/1) # title might be nil
|> Map.update(:title, "", fn title -> String.trim(title || "") end)
|> Map.put(:text, text) |> Map.put(:text, text)
end end
end end

View File

@ -70,7 +70,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do
participant, participant,
Map.get(args, :locale, "en") Map.get(args, :locale, "en")
) )
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
end end
{:ok, participant} {:ok, participant}

View File

@ -115,7 +115,7 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
def create_user(_parent, args, _resolution) do def create_user(_parent, args, _resolution) do
with :registration_ok <- check_registration_config(args), with :registration_ok <- check_registration_config(args),
{:ok, %User{} = user} <- Users.register(args), {:ok, %User{} = user} <- Users.register(args),
{:ok, %Bamboo.Email{}} <- %Bamboo.Email{} <-
Email.User.send_confirmation_email(user, Map.get(args, :locale, "en")) do Email.User.send_confirmation_email(user, Map.get(args, :locale, "en")) do
{:ok, user} {:ok, user}
else else
@ -206,7 +206,7 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
Users.get_user_by_email(email, activated: true, unconfirmed: false), Users.get_user_by_email(email, activated: true, unconfirmed: false),
{:can_reset_password, true} <- {:can_reset_password, true} <-
{:can_reset_password, Authenticator.can_reset_password?(user)}, {: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 Email.User.send_password_reset_email(user, Map.get(args, :locale, locale)) do
{:ok, email} {:ok, email}
else else
@ -358,11 +358,11 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
{:ok, %User{} = user} <- Users.update_user_email(user, new_email) do {:ok, %User{} = user} <- Users.update_user_email(user, new_email) do
user user
|> Email.User.send_email_reset_old_email() |> Email.User.send_email_reset_old_email()
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
user user
|> Email.User.send_email_reset_new_email() |> Email.User.send_email_reset_new_email()
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
{:ok, user} {:ok, user}
else else

View File

@ -16,7 +16,7 @@ defmodule Mobilizon do
alias Mobilizon.{Config, Storage, Web} alias Mobilizon.{Config, Storage, Web}
alias Mobilizon.Federation.ActivityPub alias Mobilizon.Federation.ActivityPub
alias Mobilizon.Service.ErrorPage alias Mobilizon.Service.{ErrorPage, ErrorReporter}
alias Mobilizon.Service.Export.{Feed, ICalendar} alias Mobilizon.Service.Export.{Feed, ICalendar}
@name Mix.Project.config()[:name] @name Mix.Project.config()[:name]
@ -66,6 +66,16 @@ defmodule Mobilizon do
] ++ ] ++
task_children(@env) task_children(@env)
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) Supervisor.start_link(children, strategy: :one_for_one, name: Mobilizon.Supervisor)
end end

View File

@ -1282,11 +1282,13 @@ defmodule Mobilizon.Actors do
@doc """ @doc """
Whether the actor needs to be updated. 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 @spec needs_update?(Actor.t()) :: boolean
def needs_update?(%Actor{domain: nil}), do: false 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), def needs_update?(%Actor{last_refreshed_at: nil, domain: domain}) when not is_nil(domain),
do: true do: true

View 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

View File

@ -23,7 +23,7 @@ defmodule Mobilizon.Service.Workers.Notification do
Users.get_user_with_settings!(user_id) do Users.get_user_with_settings!(user_id) do
email email
|> Notification.before_event_notification(participant, locale) |> Notification.before_event_notification(participant, locale)
|> Mailer.deliver_later() |> Mailer.send_email_later()
:ok :ok
end end
@ -48,7 +48,7 @@ defmodule Mobilizon.Service.Workers.Notification do
true <- length(participations) > 0 do true <- length(participations) > 0 do
user user
|> Notification.on_day_notification(participations, total, locale) |> Notification.on_day_notification(participations, total, locale)
|> Mailer.deliver_later() |> Mailer.send_email_later()
:ok :ok
else else
@ -77,7 +77,7 @@ defmodule Mobilizon.Service.Workers.Notification do
true <- length(participations) > 0 do true <- length(participations) > 0 do
user user
|> Notification.weekly_notification(participations, total, locale) |> Notification.weekly_notification(participations, total, locale)
|> Mailer.deliver_later() |> Mailer.send_email_later()
:ok :ok
else else
@ -99,7 +99,7 @@ defmodule Mobilizon.Service.Workers.Notification do
Events.list_participants_for_event(event_id, [:not_approved]) do Events.list_participants_for_event(event_id, [:not_approved]) do
user user
|> Notification.pending_participation_notification(event, total) |> Notification.pending_participation_notification(event, total)
|> Mailer.deliver_later() |> Mailer.send_email_later()
:ok :ok
else else

View File

@ -23,7 +23,8 @@ defmodule Mobilizon.Web.Auth.Context do
context = context =
case Guardian.Plug.current_resource(conn) do 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) Map.put(context, :current_user, user)
nil -> nil ->

View File

@ -143,6 +143,6 @@ defmodule Mobilizon.Web.Email.Event do
) do ) do
email email
|> Email.Event.event_updated(actor, old_event, event, diff, timezone, locale) |> Email.Event.event_updated(actor, old_event, event, diff, timezone, locale)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
end end
end end

View File

@ -62,7 +62,7 @@ defmodule Mobilizon.Web.Email.Follow do
|> assign(:follower, follower) |> assign(:follower, follower)
|> assign(:subject, subject) |> assign(:subject, subject)
|> render(:instance_follow) |> render(:instance_follow)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
:ok :ok
end end

View File

@ -42,7 +42,7 @@ defmodule Mobilizon.Web.Email.Group do
|> assign(:group, group) |> assign(:group, group)
|> assign(:subject, subject) |> assign(:subject, subject)
|> render(:group_invite) |> render(:group_invite)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
:ok :ok
end end
@ -70,7 +70,7 @@ defmodule Mobilizon.Web.Email.Group do
|> assign(:group, group) |> assign(:group, group)
|> assign(:subject, subject) |> assign(:subject, subject)
|> render(:group_member_removal) |> render(:group_member_removal)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
:ok :ok
end end
@ -107,7 +107,7 @@ defmodule Mobilizon.Web.Email.Group do
|> assign(:subject, subject) |> assign(:subject, subject)
|> assign(:instance, instance) |> assign(:instance, instance)
|> render(:group_suspension) |> render(:group_suspension)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
:ok :ok
end end
@ -147,7 +147,7 @@ defmodule Mobilizon.Web.Email.Group do
|> assign(:instance, instance) |> assign(:instance, instance)
|> assign(:author, author) |> assign(:author, author)
|> render(:group_deletion) |> render(:group_deletion)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
:ok :ok
else else

View File

@ -3,4 +3,28 @@ defmodule Mobilizon.Web.Email.Mailer do
Mobilizon Mailer. Mobilizon Mailer.
""" """
use Bamboo.Mailer, otp_app: :mobilizon use Bamboo.Mailer, otp_app: :mobilizon
def send_email_later(email) 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
def send_email(email) 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

View File

@ -28,7 +28,7 @@ defmodule Mobilizon.Web.Email.Participation do
email email
|> participation_updated(participation, locale) |> participation_updated(participation, locale)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
end end
:ok :ok
@ -40,7 +40,7 @@ defmodule Mobilizon.Web.Email.Participation do
with %User{locale: locale} = user <- Users.get_user!(user_id) do with %User{locale: locale} = user <- Users.get_user!(user_id) do
user user
|> participation_updated(participation, locale) |> participation_updated(participation, locale)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
:ok :ok
end end

View File

@ -80,7 +80,7 @@ defmodule Mobilizon.Web.Email.User do
Users.update_user(user, %{ Users.update_user(user, %{
"confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second) "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}") Logger.info("Sent confirmation email again to #{user.email}")
{:ok, user.email} {:ok, user.email}
end end
@ -90,7 +90,7 @@ defmodule Mobilizon.Web.Email.User do
def send_confirmation_email(%User{} = user, locale \\ "en") do def send_confirmation_email(%User{} = user, locale \\ "en") do
user user
|> Email.User.confirmation_email(locale) |> Email.User.confirmation_email(locale)
|> Email.Mailer.deliver_later() |> Email.Mailer.send_email_later()
end end
@doc """ @doc """
@ -132,10 +132,10 @@ defmodule Mobilizon.Web.Email.User do
"reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second) "reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
}) })
), ),
{:ok, %Bamboo.Email{} = mail} <- %Bamboo.Email{} = mail <-
user_updated user_updated
|> Email.User.reset_password_email(locale) |> Email.User.reset_password_email(locale)
|> Email.Mailer.deliver_later() do |> Email.Mailer.send_email_later() do
{:ok, mail} {:ok, mail}
else else
{:error, reason} -> {:error, reason} {:error, reason} -> {:error, reason}