fix: fix Elixir 1.15 depreciations

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-08-02 09:59:09 +02:00
parent 5373f1378f
commit da70427e32
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
22 changed files with 48 additions and 48 deletions

View file

@ -70,7 +70,7 @@ defmodule Mobilizon.Federation.ActivityPub do
handle_existing_entity(url, entity, options) handle_existing_entity(url, entity, options)
{:error, e} -> {:error, e} ->
Logger.warn("Something failed while fetching url #{url} #{inspect(e)}") Logger.warning("Something failed while fetching url #{url} #{inspect(e)}")
{:error, e} {:error, e}
end end
else else

View file

@ -65,7 +65,7 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do
{:error, :transmogrifier_error} {:error, :transmogrifier_error}
end end
else else
Logger.warn("Object origin check failed") Logger.warning("Object origin check failed")
{:error, :object_origin_check_failed} {:error, :object_origin_check_failed}
end end
@ -89,7 +89,7 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do
"object" => data "object" => data
}) })
else else
Logger.warn("Object origin check failed") Logger.warning("Object origin check failed")
{:error, :object_origin_check_failed} {:error, :object_origin_check_failed}
end end

View file

@ -89,13 +89,13 @@ defmodule Mobilizon.Federation.ActivityPub.Permission do
_ -> _ ->
case permission do case permission do
:access -> :access ->
Logger.warn("Actor #{actor_url} can't access #{object.url}") Logger.warning("Actor #{actor_url} can't access #{object.url}")
:update -> :update ->
Logger.warn("Actor #{actor_url} can't update #{object.url}") Logger.warning("Actor #{actor_url} can't update #{object.url}")
:delete -> :delete ->
Logger.warn("Actor #{actor_url} can't delete #{object.url}") Logger.warning("Actor #{actor_url} can't delete #{object.url}")
end end
false false

View file

@ -56,11 +56,11 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
{:ok, activity, follow} {:ok, activity, follow}
else else
{:error, :person_no_follow} -> {:error, :person_no_follow} ->
Logger.warn("Only group and instances can be followed") Logger.warning("Only group and instances can be followed")
{:error, :person_no_follow} {:error, :person_no_follow}
{:error, e} -> {:error, e} ->
Logger.warn("Error while following remote instance: #{inspect(e)}") Logger.warning("Error while following remote instance: #{inspect(e)}")
{:error, e} {:error, e}
end end
end end
@ -78,7 +78,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
{:ok, activity, follow} {:ok, activity, follow}
else else
{:error, e} -> {:error, e} ->
Logger.warn("Error while unfollowing remote instance: #{inspect(e)}") Logger.warning("Error while unfollowing remote instance: #{inspect(e)}")
{:error, e} {:error, e}
end end
end end
@ -96,7 +96,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
{:ok, activity, follow} {:ok, activity, follow}
else else
{:error, e} -> {:error, e} ->
Logger.warn("Error while accepting remote instance follow: #{inspect(e)}") Logger.warning("Error while accepting remote instance follow: #{inspect(e)}")
{:error, e} {:error, e}
end end
end end
@ -114,7 +114,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
{:ok, activity, follow} {:ok, activity, follow}
else else
{:error, e} -> {:error, e} ->
Logger.warn("Error while rejecting remote instance follow: #{inspect(e)}") Logger.warning("Error while rejecting remote instance follow: #{inspect(e)}")
{:error, e} {:error, e}
end end
end end
@ -137,7 +137,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
}) })
else else
{:error, e} -> {:error, e} ->
Logger.warn("Error while refreshing remote instance: #{inspect(e)}") Logger.warning("Error while refreshing remote instance: #{inspect(e)}")
{:error, e} {:error, e}
end end
end end

View file

@ -203,7 +203,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
Actions.Delete.delete(entity, Relay.get_actor(), false) Actions.Delete.delete(entity, Relay.get_actor(), false)
{:error, err} -> {:error, err} ->
Logger.warn("Error while fetching object from URL: #{inspect(err)}") Logger.warning("Error while fetching object from URL: #{inspect(err)}")
:error :error
end end
end end
@ -219,11 +219,11 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:ok, activity, object} {:ok, activity, object}
else else
{:error, :person_no_follow} -> {:error, :person_no_follow} ->
Logger.warn("Only group and instances can be followed") Logger.warning("Only group and instances can be followed")
:error :error
{:error, e} -> {:error, e} ->
Logger.warn("Unable to handle Follow activity #{inspect(e)}") Logger.warning("Unable to handle Follow activity #{inspect(e)}")
:error :error
end end
end end
@ -325,14 +325,14 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
:error :error
{:object_not_found, nil} -> {:object_not_found, nil} ->
Logger.warn( Logger.warning(
"Unable to process Accept activity #{inspect(id)}. Object #{inspect(accepted_object)} wasn't found." "Unable to process Accept activity #{inspect(id)}. Object #{inspect(accepted_object)} wasn't found."
) )
:error :error
e -> e ->
Logger.warn( Logger.warning(
"Unable to process Accept activity #{inspect(id)} for object #{inspect(accepted_object)} only returned #{inspect(e)}" "Unable to process Accept activity #{inspect(id)} for object #{inspect(accepted_object)} only returned #{inspect(e)}"
) )
@ -353,14 +353,14 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:ok, activity, object} {:ok, activity, object}
else else
{:object_not_found, nil} -> {:object_not_found, nil} ->
Logger.warn( Logger.warning(
"Unable to process Reject activity #{inspect(id)}. Object #{inspect(rejected_object)} wasn't found." "Unable to process Reject activity #{inspect(id)}. Object #{inspect(rejected_object)} wasn't found."
) )
:error :error
e -> e ->
Logger.warn( Logger.warning(
"Unable to process Reject activity #{inspect(id)} for object #{inspect(rejected_object)} only returned #{inspect(e)}" "Unable to process Reject activity #{inspect(id)} for object #{inspect(rejected_object)} only returned #{inspect(e)}"
) )
@ -405,7 +405,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:ok, activity, new_actor} {:ok, activity, new_actor}
else else
{:error, :update_not_allowed} -> {:error, :update_not_allowed} ->
Logger.warn( Logger.warning(
"Activity tried to update an actor that's local or not a group: #{inspect(params)}" "Activity tried to update an actor that's local or not a group: #{inspect(params)}"
) )
@ -485,7 +485,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:ok, activity, new_post} {:ok, activity, new_post}
else else
{:origin_check, _} -> {:origin_check, _} ->
Logger.warn("Actor tried to update a post but doesn't has the required role") Logger.warning("Actor tried to update a post but doesn't has the required role")
:error :error
_e -> _e ->
@ -692,7 +692,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:ok, activity, object} {:ok, activity, object}
else else
{:only_organizer, true} -> {:only_organizer, true} ->
Logger.warn( Logger.warning(
"Actor #{inspect(actor)} tried to leave event #{inspect(object)} but it was the only organizer so we didn't detach it" "Actor #{inspect(actor)} tried to leave event #{inspect(object)} but it was the only organizer so we didn't detach it"
) )
@ -742,14 +742,14 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
Actions.Remove.remove(member, group, moderator, false) Actions.Remove.remove(member, group, moderator, false)
else else
{:is_admin, {:ok, %Member{}}} -> {:is_admin, {:ok, %Member{}}} ->
Logger.warn( Logger.warning(
"Person #{inspect(actor)} is not an admin from #{inspect(origin)} and can't remove member #{inspect(object)}" "Person #{inspect(actor)} is not an admin from #{inspect(origin)} and can't remove member #{inspect(object)}"
) )
{:error, "Member already removed"} {:error, "Member already removed"}
{:is_member, {:ok, %Member{role: :rejected}}} -> {:is_member, {:ok, %Member{role: :rejected}}} ->
Logger.warn("Member #{inspect(object)} already removed from #{inspect(origin)}") Logger.warning("Member #{inspect(object)} already removed from #{inspect(origin)}")
{:error, "Member already removed"} {:error, "Member already removed"}
end end
end end
@ -949,7 +949,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:ok, activity, participant} {:ok, activity, participant}
else else
{:join_event, {:ok, _activity, %Participant{role: :rejected}}} -> {:join_event, {:ok, _activity, %Participant{role: :rejected}}} ->
Logger.warn( Logger.warning(
"Tried to handle an Reject activity on a Join activity with a event object but the participant is already rejected" "Tried to handle an Reject activity on a Join activity with a event object but the participant is already rejected"
) )
@ -1100,7 +1100,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
{:ok, object} {:ok, object}
err -> err ->
Logger.warn("Error while fetching #{inspect(object)}") Logger.warning("Error while fetching #{inspect(object)}")
{:error, err} {:error, err}
end end
end end
@ -1242,7 +1242,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
Permission.can_delete_group_object?(actor, entity) do Permission.can_delete_group_object?(actor, entity) do
Actions.Delete.delete(entity, actor, false) Actions.Delete.delete(entity, actor, false)
else else
Logger.warn("Object origin check failed") Logger.warning("Object origin check failed")
:error :error
end end

View file

@ -202,7 +202,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Comment do
# Anything else is kind of a MP # Anything else is kind of a MP
{:error, parent} -> {:error, parent} ->
Logger.warn("Parent object is something we don't handle") Logger.warning("Parent object is something we don't handle")
Logger.debug(inspect(parent)) Logger.debug(inspect(parent))
data data
end end

View file

@ -57,7 +57,7 @@ defmodule Mobilizon.GraphQL.API.Reports do
end end
if antispam_response != :ok do if antispam_response != :ok do
Logger.warn("Antispam response has been #{inspect(antispam_response)}") Logger.warning("Antispam response has been #{inspect(antispam_response)}")
end end
{:ok, report} {:ok, report}

View file

@ -123,7 +123,7 @@ defmodule Mobilizon.GraphQL.Error do
defp metadata(:unknown), do: {500, dgettext("errors", "Something went wrong")} defp metadata(:unknown), do: {500, dgettext("errors", "Something went wrong")}
defp metadata(code) do defp metadata(code) do
Logger.warn("Unhandled error code: #{inspect(code)}") Logger.warning("Unhandled error code: #{inspect(code)}")
{422, to_string(code)} {422, to_string(code)}
end end

View file

@ -87,7 +87,7 @@ defmodule Mix.Tasks.Mobilizon.Actors.Refresh do
rescue rescue
_ -> _ ->
if verbose do if verbose do
Logger.warn("Failed to refresh #{username}") Logger.warning("Failed to refresh #{username}")
end end
nil nil

View file

@ -10,7 +10,7 @@ defmodule Mobilizon.Service.GitStatus do
_ -> _ ->
# Fallback on Mix version # Fallback on Mix version
Logger.warn("Could not read git commit hash, using Mix version code instead.") Logger.warning("Could not read git commit hash, using Mix version code instead.")
Mix.Project.config()[:version] Mix.Project.config()[:version]
end) end)

View file

@ -95,7 +95,7 @@ defmodule Mobilizon.Service.Notifier.Email do
end end
defp can_send_activity?(activity, user, options) do defp can_send_activity?(activity, user, options) do
Logger.warn( Logger.warning(
"Can't check if user #{inspect(user)} can be sent an activity (#{inspect(activity)}) (#{inspect(options)})" "Can't check if user #{inspect(user)} can be sent an activity (#{inspect(activity)}) (#{inspect(options)})"
) )

View file

@ -44,7 +44,7 @@ defmodule Mobilizon.Web.Auth.Guardian do
end end
rescue rescue
e in Ecto.NoResultsError -> e in Ecto.NoResultsError ->
Logger.warn("Received token claim for non existing user: #{inspect(e)}") Logger.warning("Received token claim for non existing user: #{inspect(e)}")
{:error, :no_result} {:error, :no_result}
end end
end end

View file

@ -33,7 +33,7 @@ defmodule Mobilizon.Web.AuthController do
%{assigns: %{ueberauth_failure: fails}} = conn, %{assigns: %{ueberauth_failure: fails}} = conn,
%{"provider" => provider} = _params %{"provider" => provider} = _params
) do ) do
Logger.warn("Unable to login user with #{provider} #{inspect(fails)}") Logger.warning("Unable to login user with #{provider} #{inspect(fails)}")
redirect_to_error(conn, :unknown_error, provider) redirect_to_error(conn, :unknown_error, provider)
end end
@ -75,7 +75,7 @@ defmodule Mobilizon.Web.AuthController do
}) })
else else
err -> err ->
Logger.warn("Unable to login user \"#{email}\" #{inspect(err)}") Logger.warning("Unable to login user \"#{email}\" #{inspect(err)}")
redirect_to_error(conn, :unknown_error, strategy) redirect_to_error(conn, :unknown_error, strategy)
end end
end end

View file

@ -65,7 +65,7 @@ defmodule Mobilizon.Web.FeedController do
{:error, :not_found} {:error, :not_found}
err -> err ->
Logger.warn("Unable to find feed data cached for key #{key}, returned #{inspect(err)}") Logger.warning("Unable to find feed data cached for key #{key}, returned #{inspect(err)}")
{:error, :not_found} {:error, :not_found}
end end
end end
@ -89,7 +89,7 @@ defmodule Mobilizon.Web.FeedController do
{:error, :not_found} {:error, :not_found}
err -> err ->
Logger.warn("Unable to find feed data cached for key #{key}, returned #{inspect(err)}") Logger.warning("Unable to find feed data cached for key #{key}, returned #{inspect(err)}")
{:error, :not_found} {:error, :not_found}
end end
end end

View file

@ -70,7 +70,7 @@ defmodule Mobilizon.Web.Email.Group do
%Actor{type: :Group, preferred_username: group_username}, %Actor{type: :Group, preferred_username: group_username},
user user
) do ) do
Logger.warn( Logger.warning(
"Unable to notify group follower user #{user.email} for event #{event_uuid} from group #{group_username}" "Unable to notify group follower user #{user.email} for event #{event_uuid} from group #{group_username}"
) )

View file

@ -126,7 +126,7 @@ defmodule Mobilizon.Web.ReverseProxy do
|> halt() |> halt()
{:is_url, false} -> {:is_url, false} ->
Logger.warn("Tried to reverse proxy URL #{inspect(url)}") Logger.warning("Tried to reverse proxy URL #{inspect(url)}")
conn conn
|> error_or_redirect(url, 400, "Request failed", opts) |> error_or_redirect(url, 400, "Request failed", opts)
@ -202,7 +202,7 @@ defmodule Mobilizon.Web.ReverseProxy do
halt(conn) halt(conn)
{:error, error, conn} -> {:error, error, conn} ->
Logger.warn( Logger.warning(
"#{__MODULE__} request to #{url} failed while reading/chunking: #{inspect(error)}" "#{__MODULE__} request to #{url} failed while reading/chunking: #{inspect(error)}"
) )

View file

@ -1,3 +1,3 @@
<%= gettext "Your participation to %{event} on %{instance} has been cancelled!", event: @event.title, instance: @instance_name %> <%= gettext "Your participation to %{event} on %{instance} has been cancelled!", event: @event.title, instance: @instance_name %>
== ==
<%= gettext "Your instance's moderation team has decided to suspend %{actor_name} (%{actor_address}). All of their events have been removed and your participation to event %{event} cancelled.", actor_name: @actor.name || @actor.preferred_username, event: @event.title, actor_address: if @actor.domain, do: "@#{@actor.preferred_username}@#{@actor.domain}", else: "@#{@actor.preferred_username}" %> <%= gettext "Your instance's moderation team has decided to suspend %{actor_name} (%{actor_address}). All of their events have been removed and your participation to event %{event} cancelled.", actor_name: @actor.name || @actor.preferred_username, event: @event.title, actor_address: preferred_username_and_domain(@actor) %>

View file

@ -1,6 +1,6 @@
<%= gettext "The group %{group} has been suspended on %{instance}!", group: (@group.name || @group.preferred_username), instance: @instance_name %> <%= gettext "The group %{group} has been suspended on %{instance}!", group: (@group.name || @group.preferred_username), instance: @instance_name %>
== ==
<%= gettext "Your instance's moderation team has decided to suspend %{group_name} (%{group_address}). You are no longer a member of this group.", group_name: @group.name, group_address: if @group.domain, do: "@#{@group.preferred_username}@#{@group.domain}", else: "@#{@group.preferred_username}" %> <%= gettext "Your instance's moderation team has decided to suspend %{group_name} (%{group_address}). You are no longer a member of this group.", group_name: @group.name, group_address: preferred_username_and_domain(@group) %>
<%= if is_nil(@group.domain) do %> <%= if is_nil(@group.domain) do %>
<%= gettext "As this group was located on this instance, all of it's data has been irretrievably deleted." %> <%= gettext "As this group was located on this instance, all of it's data has been irretrievably deleted." %>
<% else %> <% else %>

View file

@ -25,7 +25,7 @@ defmodule Mobilizon.Web.Upload.Filter.AnalyzeMetadata do
rescue rescue
e in ErlangError -> e in ErlangError ->
require Logger require Logger
Logger.warn("#{__MODULE__}: #{inspect(e)}") Logger.warning("#{__MODULE__}: #{inspect(e)}")
{:ok, :noop} {:ok, :noop}
end end

View file

@ -15,7 +15,7 @@ defmodule Mobilizon.Web.Upload.Filter.BlurHash do
{:ok, :filtered, %Upload{upload | blurhash: generate_blurhash(file)}} {:ok, :filtered, %Upload{upload | blurhash: generate_blurhash(file)}}
rescue rescue
e in ErlangError -> e in ErlangError ->
Logger.warn("#{__MODULE__}: #{inspect(e)}") Logger.warning("#{__MODULE__}: #{inspect(e)}")
{:ok, :noop} {:ok, :noop}
end end

View file

@ -28,11 +28,11 @@ defmodule Mobilizon.Web.Upload.Filter.Optimize do
{:ok, :filtered} {:ok, :filtered}
{:error, :file_not_found} -> {:error, :file_not_found} ->
Logger.warn("Unable to optimize file #{file}. File was not found") Logger.warning("Unable to optimize file #{file}. File was not found")
{:error, :file_not_found} {:error, :file_not_found}
{:error, err} -> {:error, err} ->
Logger.warn( Logger.warning(
"Unable to optimize file #{file}. The return from the process was #{inspect(err)}" "Unable to optimize file #{file}. The return from the process was #{inspect(err)}"
) )

View file

@ -70,7 +70,7 @@ defmodule Mobilizon.Web.ErrorView do
# template is found, let's render it as 500 # template is found, let's render it as 500
def template_not_found(template, assigns) do def template_not_found(template, assigns) do
require Logger require Logger
Logger.warn("Template #{inspect(template)} not found") Logger.warning("Template #{inspect(template)} not found")
render("500.html", assigns) render("500.html", assigns)
end end
end end