Merge branch 'fixes' into 'main'
Final round of fixes Closes #1187 et #1183 See merge request framasoft/mobilizon!1334
This commit is contained in:
commit
34a0b181f7
|
@ -637,6 +637,10 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
|
|||
{:error, err} ->
|
||||
Logger.debug(inspect(err))
|
||||
{:error, err}
|
||||
|
||||
{:error, :http_not_found, err} ->
|
||||
Logger.debug(inspect(err))
|
||||
{:error, err}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ defmodule Mobilizon.Storage.Page do
|
|||
fn -> Repo.all(paginate(query, page, limit)) end
|
||||
]
|
||||
|> Enum.map(&Task.async/1)
|
||||
|> Enum.map(&Task.await/1)
|
||||
|> Enum.map(&Task.await(&1, 15_000))
|
||||
|
||||
%__MODULE__{total: total, elements: elements}
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ defmodule Mobilizon.Service.ActorSuspension do
|
|||
|
||||
@actor_preloads [:user, :organized_events, :participations, :comments]
|
||||
@delete_actor_default_options [reserve_username: true, suspension: false]
|
||||
@valid_actor_types [:Person, :Group]
|
||||
|
||||
@doc """
|
||||
Deletes an actor.
|
||||
|
@ -119,7 +120,8 @@ defmodule Mobilizon.Service.ActorSuspension do
|
|||
end
|
||||
|
||||
@spec notify_event_participants_from_suspension(Actor.t()) :: :ok
|
||||
defp notify_event_participants_from_suspension(%Actor{id: actor_id} = actor) do
|
||||
defp notify_event_participants_from_suspension(%Actor{id: actor_id, type: actor_type} = actor)
|
||||
when actor_type in @valid_actor_types do
|
||||
actor
|
||||
|> get_actor_organizer_events_participations()
|
||||
|> preload([:actor, :event])
|
||||
|
@ -134,6 +136,8 @@ defmodule Mobilizon.Service.ActorSuspension do
|
|||
|> Enum.each(&Events.delete_participant/1)
|
||||
end
|
||||
|
||||
defp notify_event_participants_from_suspension(_), do: :ok
|
||||
|
||||
@spec get_actor_organizer_events_participations(Actor.t()) :: Ecto.Query.t()
|
||||
defp get_actor_organizer_events_participations(%Actor{type: :Person, id: actor_id}) do
|
||||
do_get_actor_organizer_events_participations()
|
||||
|
|
|
@ -94,6 +94,15 @@ defmodule Mobilizon.Service.Notifier.Email do
|
|||
)
|
||||
end
|
||||
|
||||
defp can_send_activity?(activity, user, options) do
|
||||
Logger.warn("Can't check if user #{inspect(user)} can be sent an activity",
|
||||
activity: inspect(activity),
|
||||
options: inspect(options)
|
||||
)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
@spec match_group_notifications_setting(
|
||||
non_neg_integer(),
|
||||
String.t(),
|
||||
|
|
|
@ -24,7 +24,9 @@ defmodule Mobilizon.Service.Pictures.Unsplash do
|
|||
GenericJSONClient.client(headers: [{:Authorization, "Client-ID #{unsplash_access_key()}"}])
|
||||
|
||||
with {:ok, %{status: 200, body: body}} <- GenericJSONClient.get(client, url),
|
||||
selected_picture <- Enum.random(body["results"]) do
|
||||
results <- body["results"],
|
||||
{:empty, false} <- {:empty, Enum.empty?(results)},
|
||||
selected_picture <- Enum.random(results) do
|
||||
%Information{
|
||||
url: selected_picture["urls"]["small"],
|
||||
author: %{
|
||||
|
@ -37,6 +39,9 @@ defmodule Mobilizon.Service.Pictures.Unsplash do
|
|||
}
|
||||
}
|
||||
else
|
||||
{:empty, false} ->
|
||||
nil
|
||||
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -11,6 +11,7 @@ defmodule Mobilizon.Web.Email.Group do
|
|||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Users.{Setting, User}
|
||||
alias Mobilizon.Web.Email
|
||||
require Logger
|
||||
|
||||
@spec notify_of_new_event(Event.t()) :: :ok
|
||||
def notify_of_new_event(%Event{attributed_to: %Actor{} = group} = event) do
|
||||
|
@ -63,6 +64,20 @@ defmodule Mobilizon.Web.Email.Group do
|
|||
end
|
||||
end
|
||||
|
||||
defp notify_follower(
|
||||
%Event{uuid: event_uuid},
|
||||
%Actor{type: :Group, preferred_username: group_username},
|
||||
user
|
||||
) do
|
||||
Logger.warn(
|
||||
"Unable to notify group follower user #{user.email} for event #{event_uuid} from group #{group_username}"
|
||||
)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
defp notify_follower(_, _, _), do: :ok
|
||||
|
||||
@spec accepts_new_events_notifications(list()) :: boolean()
|
||||
defp accepts_new_events_notifications(activity_settings) do
|
||||
case Enum.find(activity_settings, &(&1.key == "event_created" && &1.method == "email")) do
|
||||
|
|
Loading…
Reference in a new issue