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",
"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}",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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é",

View file

@ -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}",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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} отправлена",

View file

@ -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}",

View file

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

View file

@ -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}
@ -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}

View file

@ -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

View file

@ -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}

View file

@ -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
@ -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

View file

@ -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]
@ -66,6 +66,16 @@ defmodule Mobilizon do
] ++
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)
end

View file

@ -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

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
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

View file

@ -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 ->

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -3,4 +3,28 @@ defmodule Mobilizon.Web.Email.Mailer do
Mobilizon Mailer.
"""
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

View file

@ -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

View file

@ -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
@ -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 """
@ -132,10 +132,10 @@ 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.deliver_later() do
|> Email.Mailer.send_email_later() do
{:ok, mail}
else
{:error, reason} -> {:error, reason}