Fix Dialyzer warnings
This commit is contained in:
parent
87e8d792bd
commit
22018adae6
16 changed files with 35 additions and 41 deletions
|
@ -186,11 +186,7 @@ def run(["gen-pack", src]) do
|
||||||
|
|
||||||
tmp_pack_dir = Path.join(System.tmp_dir!(), "emoji-pack-#{name}")
|
tmp_pack_dir = Path.join(System.tmp_dir!(), "emoji-pack-#{name}")
|
||||||
|
|
||||||
{:ok, _} =
|
{:ok, _} = :zip.unzip(binary_archive, cwd: String.to_charlist(tmp_pack_dir))
|
||||||
:zip.unzip(
|
|
||||||
binary_archive,
|
|
||||||
cwd: tmp_pack_dir
|
|
||||||
)
|
|
||||||
|
|
||||||
emoji_map = Pleroma.Emoji.Loader.make_shortcode_to_file_map(tmp_pack_dir, exts)
|
emoji_map = Pleroma.Emoji.Loader.make_shortcode_to_file_map(tmp_pack_dir, exts)
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,7 @@ def run(["rm", nickname]) do
|
||||||
User.perform(:delete, user)
|
User.perform(:delete, user)
|
||||||
shell_info("User #{nickname} deleted.")
|
shell_info("User #{nickname} deleted.")
|
||||||
else
|
else
|
||||||
_ ->
|
_ -> shell_error("No local user #{nickname}")
|
||||||
shell_error("No local user #{nickname}")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ def follow_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do
|
||||||
|
|
||||||
def restrict_deactivated_users(query) do
|
def restrict_deactivated_users(query) do
|
||||||
deactivated_users =
|
deactivated_users =
|
||||||
from(u in User.Query.build(deactivated: true), select: u.ap_id)
|
from(u in User.Query.build(%{deactivated: true}), select: u.ap_id)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
||||||
Activity.Queries.exclude_authors(query, deactivated_users)
|
Activity.Queries.exclude_authors(query, deactivated_users)
|
||||||
|
|
|
@ -30,7 +30,7 @@ def by_actor(query \\ Activity, actor) do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec by_author(query, String.t()) :: query
|
@spec by_author(query, User.t()) :: query
|
||||||
def by_author(query \\ Activity, %User{ap_id: ap_id}) do
|
def by_author(query \\ Activity, %User{ap_id: ap_id}) do
|
||||||
from(a in query, where: a.actor == ^ap_id)
|
from(a in query, where: a.actor == ^ap_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,8 +10,8 @@ defmodule Pleroma.Captcha.Native do
|
||||||
@impl Service
|
@impl Service
|
||||||
def new do
|
def new do
|
||||||
case Captcha.get() do
|
case Captcha.get() do
|
||||||
{:timeout} ->
|
:error ->
|
||||||
%{error: dgettext("errors", "Captcha timeout")}
|
%{error: dgettext("errors", "Captcha error")}
|
||||||
|
|
||||||
{:ok, answer_data, img_binary} ->
|
{:ok, answer_data, img_binary} ->
|
||||||
%{
|
%{
|
||||||
|
|
|
@ -133,10 +133,8 @@ def restrict_recipients(query, user, %{"recipients" => user_ids}) do
|
||||||
[user.id | user_ids]
|
[user.id | user_ids]
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|> Enum.reduce([], fn user_id, acc ->
|
|> Enum.reduce([], fn user_id, acc ->
|
||||||
case FlakeId.Ecto.CompatType.dump(user_id) do
|
{:ok, user_id} = FlakeId.Ecto.CompatType.dump(user_id)
|
||||||
{:ok, user_id} -> [user_id | acc]
|
[user_id | acc]
|
||||||
_ -> acc
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
conversation_subquery =
|
conversation_subquery =
|
||||||
|
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.MIME do
|
||||||
@default "application/octet-stream"
|
@default "application/octet-stream"
|
||||||
@read_bytes 35
|
@read_bytes 35
|
||||||
|
|
||||||
@spec file_mime_type(String.t()) ::
|
@spec file_mime_type(String.t(), String.t()) ::
|
||||||
{:ok, content_type :: String.t(), filename :: String.t()} | {:error, any()} | :error
|
{:ok, content_type :: String.t(), filename :: String.t()} | {:error, any()} | :error
|
||||||
def file_mime_type(path, filename) do
|
def file_mime_type(path, filename) do
|
||||||
with {:ok, content_type} <- file_mime_type(path),
|
with {:ok, content_type} <- file_mime_type(path),
|
||||||
|
|
|
@ -39,15 +39,8 @@ def get_actor(%{"actor" => nil, "attributedTo" => actor}) when not is_nil(actor)
|
||||||
defp compare_uris(_, %URI{scheme: "tag"}), do: :ok
|
defp compare_uris(_, %URI{scheme: "tag"}), do: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
defp compare_uris(%URI{} = id_uri, %URI{} = other_uri) do
|
defp compare_uris(%URI{host: host} = _id_uri, %URI{host: host} = _other_uri), do: :ok
|
||||||
if id_uri.host == other_uri.host do
|
defp compare_uris(_id_uri, _other_uri), do: :error
|
||||||
:ok
|
|
||||||
else
|
|
||||||
:error
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp compare_uris(_, _), do: :error
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Checks that an imported AP object's actor matches the domain it came from.
|
Checks that an imported AP object's actor matches the domain it came from.
|
||||||
|
|
|
@ -853,14 +853,14 @@ def get_followers_query(user, page) do
|
||||||
@spec get_followers_query(User.t()) :: Ecto.Query.t()
|
@spec get_followers_query(User.t()) :: Ecto.Query.t()
|
||||||
def get_followers_query(user), do: get_followers_query(user, nil)
|
def get_followers_query(user), do: get_followers_query(user, nil)
|
||||||
|
|
||||||
@spec get_followers(User.t(), pos_integer()) :: {:ok, list(User.t())}
|
@spec get_followers(User.t(), pos_integer() | nil) :: {:ok, list(User.t())}
|
||||||
def get_followers(user, page \\ nil) do
|
def get_followers(user, page \\ nil) do
|
||||||
user
|
user
|
||||||
|> get_followers_query(page)
|
|> get_followers_query(page)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec get_external_followers(User.t(), pos_integer()) :: {:ok, list(User.t())}
|
@spec get_external_followers(User.t(), pos_integer() | nil) :: {:ok, list(User.t())}
|
||||||
def get_external_followers(user, page \\ nil) do
|
def get_external_followers(user, page \\ nil) do
|
||||||
user
|
user
|
||||||
|> get_followers_query(page)
|
|> get_followers_query(page)
|
||||||
|
@ -1304,7 +1304,6 @@ def perform(:delete, %User{} = user) do
|
||||||
Repo.delete(user)
|
Repo.delete(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec perform(atom(), User.t()) :: {:ok, User.t()}
|
|
||||||
def perform(:fetch_initial_posts, %User{} = user) do
|
def perform(:fetch_initial_posts, %User{} = user) do
|
||||||
pages = Pleroma.Config.get!([:fetch_initial_posts, :pages])
|
pages = Pleroma.Config.get!([:fetch_initial_posts, :pages])
|
||||||
|
|
||||||
|
@ -1336,7 +1335,6 @@ def perform(:blocks_import, %User{} = blocker, blocked_identifiers)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec perform(atom(), User.t(), list()) :: list() | {:error, any()}
|
|
||||||
def perform(:follow_import, %User{} = follower, followed_identifiers)
|
def perform(:follow_import, %User{} = follower, followed_identifiers)
|
||||||
when is_list(followed_identifiers) do
|
when is_list(followed_identifiers) do
|
||||||
Enum.map(
|
Enum.map(
|
||||||
|
|
|
@ -48,7 +48,7 @@ defmodule Pleroma.User.Query do
|
||||||
followers: User.t(),
|
followers: User.t(),
|
||||||
friends: User.t(),
|
friends: User.t(),
|
||||||
recipients_from_activity: [String.t()],
|
recipients_from_activity: [String.t()],
|
||||||
nickname: [String.t()],
|
nickname: [String.t()] | String.t(),
|
||||||
ap_id: [String.t()],
|
ap_id: [String.t()],
|
||||||
order_by: term(),
|
order_by: term(),
|
||||||
select: term(),
|
select: term(),
|
||||||
|
|
|
@ -33,9 +33,15 @@ defp format_query(query_string) do
|
||||||
# Strip the beginning @ off if there is a query
|
# Strip the beginning @ off if there is a query
|
||||||
query_string = String.trim_leading(query_string, "@")
|
query_string = String.trim_leading(query_string, "@")
|
||||||
|
|
||||||
with [name, domain] <- String.split(query_string, "@"),
|
with [name, domain] <- String.split(query_string, "@") do
|
||||||
formatted_domain <- String.replace(domain, ~r/[!-\-|@|[-`|{-~|\/|:|\s]+/, "") do
|
encoded_domain =
|
||||||
name <> "@" <> to_string(:idna.encode(formatted_domain))
|
domain
|
||||||
|
|> String.replace(~r/[!-\-|@|[-`|{-~|\/|:|\s]+/, "")
|
||||||
|
|> String.to_charlist()
|
||||||
|
|> :idna.encode()
|
||||||
|
|> to_string()
|
||||||
|
|
||||||
|
name <> "@" <> encoded_domain
|
||||||
else
|
else
|
||||||
_ -> query_string
|
_ -> query_string
|
||||||
end
|
end
|
||||||
|
|
|
@ -160,7 +160,7 @@ def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
||||||
|
|
||||||
if Federator.allowed_thread_distance?(depth) do
|
if Federator.allowed_thread_distance?(depth) do
|
||||||
with {:ok, replied_object} <- get_obj_helper(in_reply_to_id, options),
|
with {:ok, replied_object} <- get_obj_helper(in_reply_to_id, options),
|
||||||
%Activity{} = _ <- Activity.get_create_by_object_ap_id(replied_object.data["id"]) do
|
%Activity{} <- Activity.get_create_by_object_ap_id(replied_object.data["id"]) do
|
||||||
object
|
object
|
||||||
|> Map.put("inReplyTo", replied_object.data["id"])
|
|> Map.put("inReplyTo", replied_object.data["id"])
|
||||||
|> Map.put("inReplyToAtomUri", object["inReplyToAtomUri"] || in_reply_to_id)
|
|> Map.put("inReplyToAtomUri", object["inReplyToAtomUri"] || in_reply_to_id)
|
||||||
|
|
|
@ -45,8 +45,8 @@ def normalize_params(params) do
|
||||||
Map.put(params, "actor", get_ap_id(params["actor"]))
|
Map.put(params, "actor", get_ap_id(params["actor"]))
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec determine_explicit_mentions(map()) :: map()
|
@spec determine_explicit_mentions(map()) :: [any]
|
||||||
def determine_explicit_mentions(%{"tag" => tag} = _) when is_list(tag) do
|
def determine_explicit_mentions(%{"tag" => tag}) when is_list(tag) do
|
||||||
Enum.flat_map(tag, fn
|
Enum.flat_map(tag, fn
|
||||||
%{"type" => "Mention", "href" => href} -> [href]
|
%{"type" => "Mention", "href" => href} -> [href]
|
||||||
_ -> []
|
_ -> []
|
||||||
|
@ -427,7 +427,7 @@ defp fetch_likes(object) do
|
||||||
@doc """
|
@doc """
|
||||||
Updates a follow activity's state (for locked accounts).
|
Updates a follow activity's state (for locked accounts).
|
||||||
"""
|
"""
|
||||||
@spec update_follow_state_for_all(Activity.t(), String.t()) :: {:ok, Activity} | {:error, any()}
|
@spec update_follow_state_for_all(Activity.t(), String.t()) :: {:ok, Activity | nil}
|
||||||
def update_follow_state_for_all(
|
def update_follow_state_for_all(
|
||||||
%Activity{data: %{"actor" => actor, "object" => object}} = activity,
|
%Activity{data: %{"actor" => actor, "object" => object}} = activity,
|
||||||
state
|
state
|
||||||
|
|
|
@ -18,7 +18,11 @@ defmacro not_empty_string(string) do
|
||||||
|
|
||||||
@spec user(map()) :: {:ok, [User.t()], pos_integer()}
|
@spec user(map()) :: {:ok, [User.t()], pos_integer()}
|
||||||
def user(params \\ %{}) do
|
def user(params \\ %{}) do
|
||||||
query = User.Query.build(params) |> order_by([u], u.nickname)
|
query =
|
||||||
|
params
|
||||||
|
|> Map.drop([:page, :page_size])
|
||||||
|
|> User.Query.build()
|
||||||
|
|> order_by([u], u.nickname)
|
||||||
|
|
||||||
paginated_query =
|
paginated_query =
|
||||||
User.Query.paginate(query, params[:page] || 1, params[:page_size] || @page_size)
|
User.Query.paginate(query, params[:page] || 1, params[:page_size] || @page_size)
|
||||||
|
|
|
@ -92,9 +92,9 @@ def raw_nodeinfo do
|
||||||
openRegistrations: Config.get([:instance, :registrations_open]),
|
openRegistrations: Config.get([:instance, :registrations_open]),
|
||||||
usage: %{
|
usage: %{
|
||||||
users: %{
|
users: %{
|
||||||
total: stats.user_count || 0
|
total: Map.get(stats, :user_count, 0)
|
||||||
},
|
},
|
||||||
localPosts: stats.status_count || 0
|
localPosts: Map.get(stats, :status_count, 0)
|
||||||
},
|
},
|
||||||
metadata: %{
|
metadata: %{
|
||||||
nodeName: Config.get([:instance, :name]),
|
nodeName: Config.get([:instance, :name]),
|
||||||
|
|
|
@ -323,7 +323,7 @@ def delete(conn, %{"name" => name}) do
|
||||||
{:ok, _} ->
|
{:ok, _} ->
|
||||||
conn |> json("ok")
|
conn |> json("ok")
|
||||||
|
|
||||||
{:error, _} ->
|
{:error, _, _} ->
|
||||||
conn
|
conn
|
||||||
|> put_status(:internal_server_error)
|
|> put_status(:internal_server_error)
|
||||||
|> json(%{error: "Couldn't delete the pack #{name}"})
|
|> json(%{error: "Couldn't delete the pack #{name}"})
|
||||||
|
|
Loading…
Reference in a new issue