mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 16:40:29 +00:00
Merge branch 'dialyzer-fixes' into 'develop'
Dialyzer fixes See merge request pleroma/pleroma!4047
This commit is contained in:
commit
b1659b7755
11 changed files with 20 additions and 13 deletions
0
changelog.d/dialyzer2.skip
Normal file
0
changelog.d/dialyzer2.skip
Normal file
|
@ -126,9 +126,15 @@ defmodule Pleroma.Helpers.QtFastStart do
|
||||||
<<pos::integer-big-size(unquote(size)), rest::bits>>,
|
<<pos::integer-big-size(unquote(size)), rest::bits>>,
|
||||||
acc
|
acc
|
||||||
) do
|
) do
|
||||||
rewrite_entries(unquote(size), offset, rest, [
|
rewrite_entries(
|
||||||
acc | <<pos + offset::integer-big-size(unquote(size))>>
|
unquote(size),
|
||||||
])
|
offset,
|
||||||
|
rest,
|
||||||
|
acc ++
|
||||||
|
[
|
||||||
|
<<pos + offset::integer-big-size(unquote(size))>>
|
||||||
|
]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ defmodule Pleroma.ModerationLog do
|
||||||
|
|
||||||
defp prepare_log_data(attrs), do: attrs
|
defp prepare_log_data(attrs), do: attrs
|
||||||
|
|
||||||
@spec insert_log(log_params()) :: {:ok, ModerationLog} | {:error, any}
|
@spec insert_log(log_params()) :: {:ok, ModerationLog.t()} | {:error, any}
|
||||||
def insert_log(%{actor: %User{}, subject: subjects, permission: permission} = attrs) do
|
def insert_log(%{actor: %User{}, subject: subjects, permission: permission} = attrs) do
|
||||||
data =
|
data =
|
||||||
attrs
|
attrs
|
||||||
|
@ -248,7 +248,8 @@ defmodule Pleroma.ModerationLog do
|
||||||
|> insert_log_entry_with_message()
|
|> insert_log_entry_with_message()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec insert_log_entry_with_message(ModerationLog) :: {:ok, ModerationLog} | {:error, any}
|
@spec insert_log_entry_with_message(ModerationLog.t()) ::
|
||||||
|
{:ok, ModerationLog.t()} | {:error, any}
|
||||||
defp insert_log_entry_with_message(entry) do
|
defp insert_log_entry_with_message(entry) do
|
||||||
entry.data["message"]
|
entry.data["message"]
|
||||||
|> put_in(get_log_entry_message(entry))
|
|> put_in(get_log_entry_message(entry))
|
||||||
|
|
|
@ -20,5 +20,5 @@ defmodule Pleroma.Search.SearchBackend do
|
||||||
is what contains the actual content and there is no need for filtering when removing
|
is what contains the actual content and there is no need for filtering when removing
|
||||||
from index.
|
from index.
|
||||||
"""
|
"""
|
||||||
@callback remove_from_index(object :: Pleroma.Object.t()) :: {:ok, any()} | {:error, any()}
|
@callback remove_from_index(object :: Pleroma.Object.t()) :: :ok | {:error, any()}
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ defmodule Pleroma.Signature do
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
case Pleroma.Web.WebFinger.finger(maybe_ap_id) do
|
case Pleroma.Web.WebFinger.finger(maybe_ap_id) do
|
||||||
%{"ap_id" => ap_id} -> {:ok, ap_id}
|
{:ok, %{"ap_id" => ap_id}} -> {:ok, ap_id}
|
||||||
_ -> {:error, maybe_ap_id}
|
_ -> {:error, maybe_ap_id}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -175,7 +175,7 @@ defmodule Pleroma.Upload do
|
||||||
defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
|
defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
|
||||||
parsed = Regex.named_captures(~r/(?<filetype>jpeg|png|gif);base64,(?<data>.*)/, image_data)
|
parsed = Regex.named_captures(~r/(?<filetype>jpeg|png|gif);base64,(?<data>.*)/, image_data)
|
||||||
data = Base.decode64!(parsed["data"], ignore: :whitespace)
|
data = Base.decode64!(parsed["data"], ignore: :whitespace)
|
||||||
hash = Base.encode16(:crypto.hash(:sha256, data), lower: true)
|
hash = Base.encode16(:crypto.hash(:sha256, data), case: :upper)
|
||||||
|
|
||||||
with :ok <- check_binary_size(data, opts.size_limit),
|
with :ok <- check_binary_size(data, opts.size_limit),
|
||||||
tmp_path <- tempfile_for_image(data),
|
tmp_path <- tempfile_for_image(data),
|
||||||
|
|
|
@ -105,7 +105,7 @@ defmodule Pleroma.Web.RichMedia.Parser do
|
||||||
{:ok, integer() | :noop} | {:error, :no_key}
|
{:ok, integer() | :noop} | {:error, :no_key}
|
||||||
def set_ttl_based_on_image(data, url) do
|
def set_ttl_based_on_image(data, url) do
|
||||||
case get_ttl_from_image(data, url) do
|
case get_ttl_from_image(data, url) do
|
||||||
{:ok, ttl} when is_number(ttl) ->
|
ttl when is_number(ttl) ->
|
||||||
ttl = ttl * 1000
|
ttl = ttl * 1000
|
||||||
|
|
||||||
case @cachex.expire_at(:rich_media_cache, url, ttl) do
|
case @cachex.expire_at(:rich_media_cache, url, ttl) do
|
||||||
|
|
|
@ -45,6 +45,6 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl do
|
||||||
|> Map.get("X-Amz-Date")
|
|> Map.get("X-Amz-Date")
|
||||||
|> Timex.parse("{ISO:Basic:Z}")
|
|> Timex.parse("{ISO:Basic:Z}")
|
||||||
|
|
||||||
{:ok, Timex.to_unix(date) + String.to_integer(Map.get(params, "X-Amz-Expires"))}
|
Timex.to_unix(date) + String.to_integer(Map.get(params, "X-Amz-Expires"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -319,7 +319,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
||||||
user = User.get_cached_by_nickname(nickname)
|
user = User.get_cached_by_nickname(nickname)
|
||||||
|
|
||||||
if user == nil do
|
if user == nil do
|
||||||
{:not_found, nil}
|
{:error, :not_found}
|
||||||
else
|
else
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
end
|
end
|
||||||
|
|
|
@ -113,7 +113,7 @@ defmodule Pleroma.SignatureTest do
|
||||||
|
|
||||||
test "it calls webfinger for 'acct:' accounts" do
|
test "it calls webfinger for 'acct:' accounts" do
|
||||||
with_mock(Pleroma.Web.WebFinger,
|
with_mock(Pleroma.Web.WebFinger,
|
||||||
finger: fn _ -> %{"ap_id" => "https://gensokyo.2hu/users/raymoo"} end
|
finger: fn _ -> {:ok, %{"ap_id" => "https://gensokyo.2hu/users/raymoo"}} end
|
||||||
) do
|
) do
|
||||||
assert Signature.key_id_to_actor_id("acct:raymoo@gensokyo.2hu") ==
|
assert Signature.key_id_to_actor_id("acct:raymoo@gensokyo.2hu") ==
|
||||||
{:ok, "https://gensokyo.2hu/users/raymoo"}
|
{:ok, "https://gensokyo.2hu/users/raymoo"}
|
||||||
|
|
|
@ -22,7 +22,7 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrlTest do
|
||||||
expire_time =
|
expire_time =
|
||||||
Timex.parse!(timestamp, "{ISO:Basic:Z}") |> Timex.to_unix() |> Kernel.+(valid_till)
|
Timex.parse!(timestamp, "{ISO:Basic:Z}") |> Timex.to_unix() |> Kernel.+(valid_till)
|
||||||
|
|
||||||
assert {:ok, expire_time} == Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl.ttl(metadata, url)
|
assert expire_time == Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl.ttl(metadata, url)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "s3 signed url is parsed and correct ttl is set for rich media" do
|
test "s3 signed url is parsed and correct ttl is set for rich media" do
|
||||||
|
|
Loading…
Reference in a new issue