Merge branch 'dialyzer-fixes' into 'develop'
Dialyzer fixes See merge request pleroma/pleroma!4128
This commit is contained in:
commit
3b639b467e
1
changelog.d/video-thumbs.fix
Normal file
1
changelog.d/video-thumbs.fix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Video thumbnails were not being generated due to a negative cache lookup logic error
|
@ -25,7 +25,7 @@ defmodule Pleroma.Helpers.MediaHelper do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def image_resize(url, options) do
|
def image_resize(url, options) do
|
||||||
with {:ok, env} <- HTTP.get(url, [], pool: :media),
|
with {:ok, env} <- HTTP.get(url, [], http_client_opts()),
|
||||||
{:ok, resized} <-
|
{:ok, resized} <-
|
||||||
Operation.thumbnail_buffer(env.body, options.max_width,
|
Operation.thumbnail_buffer(env.body, options.max_width,
|
||||||
height: options.max_height,
|
height: options.max_height,
|
||||||
@ -45,8 +45,8 @@ defmodule Pleroma.Helpers.MediaHelper do
|
|||||||
@spec video_framegrab(String.t()) :: {:ok, binary()} | {:error, any()}
|
@spec video_framegrab(String.t()) :: {:ok, binary()} | {:error, any()}
|
||||||
def video_framegrab(url) do
|
def video_framegrab(url) do
|
||||||
with executable when is_binary(executable) <- System.find_executable("ffmpeg"),
|
with executable when is_binary(executable) <- System.find_executable("ffmpeg"),
|
||||||
false <- @cachex.exists?(:failed_media_helper_cache, url),
|
{:ok, false} <- @cachex.exists?(:failed_media_helper_cache, url),
|
||||||
{:ok, env} <- HTTP.get(url, [], pool: :media),
|
{:ok, env} <- HTTP.get(url, [], http_client_opts()),
|
||||||
{:ok, pid} <- StringIO.open(env.body) do
|
{:ok, pid} <- StringIO.open(env.body) do
|
||||||
body_stream = IO.binstream(pid, 1)
|
body_stream = IO.binstream(pid, 1)
|
||||||
|
|
||||||
@ -71,17 +71,19 @@ defmodule Pleroma.Helpers.MediaHelper do
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
case Task.yield(task, 5_000) do
|
case Task.yield(task, 5_000) do
|
||||||
nil ->
|
{:ok, result} ->
|
||||||
|
{:ok, result}
|
||||||
|
|
||||||
|
_ ->
|
||||||
Task.shutdown(task)
|
Task.shutdown(task)
|
||||||
@cachex.put(:failed_media_helper_cache, url, nil)
|
@cachex.put(:failed_media_helper_cache, url, nil)
|
||||||
{:error, {:ffmpeg, :timeout}}
|
{:error, {:ffmpeg, :timeout}}
|
||||||
|
|
||||||
result ->
|
|
||||||
{:ok, result}
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
nil -> {:error, {:ffmpeg, :command_not_found}}
|
nil -> {:error, {:ffmpeg, :command_not_found}}
|
||||||
{:error, _} = error -> error
|
{:error, _} = error -> error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp http_client_opts, do: Pleroma.Config.get([:media_proxy, :proxy_opts, :http], pool: :media)
|
||||||
end
|
end
|
||||||
|
@ -489,7 +489,7 @@ defmodule Pleroma.Notification do
|
|||||||
|
|
||||||
NOTE: might be called for FAKE Activities, see ActivityPub.Utils.get_notified_from_object/1
|
NOTE: might be called for FAKE Activities, see ActivityPub.Utils.get_notified_from_object/1
|
||||||
"""
|
"""
|
||||||
@spec get_notified_from_activity(Activity.t(), boolean()) :: {list(User.t()), list(User.t())}
|
@spec get_notified_from_activity(Activity.t(), boolean()) :: list(User.t())
|
||||||
def get_notified_from_activity(activity, local_only \\ true)
|
def get_notified_from_activity(activity, local_only \\ true)
|
||||||
|
|
||||||
def get_notified_from_activity(%Activity{data: %{"type" => type}} = activity, local_only)
|
def get_notified_from_activity(%Activity{data: %{"type" => type}} = activity, local_only)
|
||||||
|
@ -28,7 +28,7 @@ defmodule Pleroma.Search.DatabaseSearch do
|
|||||||
|> Activity.with_preloaded_object()
|
|> Activity.with_preloaded_object()
|
||||||
|> Activity.restrict_deactivated_users()
|
|> Activity.restrict_deactivated_users()
|
||||||
|> restrict_public(user)
|
|> restrict_public(user)
|
||||||
|> query_with(index_type, search_query, :websearch)
|
|> query_with(index_type, search_query)
|
||||||
|> maybe_restrict_local(user)
|
|> maybe_restrict_local(user)
|
||||||
|> maybe_restrict_author(author)
|
|> maybe_restrict_author(author)
|
||||||
|> maybe_restrict_blocked(user)
|
|> maybe_restrict_blocked(user)
|
||||||
@ -88,25 +88,7 @@ defmodule Pleroma.Search.DatabaseSearch do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp query_with(q, :gin, search_query, :plain) do
|
defp query_with(q, :gin, search_query) do
|
||||||
%{rows: [[tsc]]} =
|
|
||||||
Ecto.Adapters.SQL.query!(
|
|
||||||
Pleroma.Repo,
|
|
||||||
"select current_setting('default_text_search_config')::regconfig::oid;"
|
|
||||||
)
|
|
||||||
|
|
||||||
from([a, o] in q,
|
|
||||||
where:
|
|
||||||
fragment(
|
|
||||||
"to_tsvector(?::oid::regconfig, ?->>'content') @@ plainto_tsquery(?)",
|
|
||||||
^tsc,
|
|
||||||
o.data,
|
|
||||||
^search_query
|
|
||||||
)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp query_with(q, :gin, search_query, :websearch) do
|
|
||||||
%{rows: [[tsc]]} =
|
%{rows: [[tsc]]} =
|
||||||
Ecto.Adapters.SQL.query!(
|
Ecto.Adapters.SQL.query!(
|
||||||
Pleroma.Repo,
|
Pleroma.Repo,
|
||||||
@ -124,19 +106,7 @@ defmodule Pleroma.Search.DatabaseSearch do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp query_with(q, :rum, search_query, :plain) do
|
defp query_with(q, :rum, search_query) do
|
||||||
from([a, o] in q,
|
|
||||||
where:
|
|
||||||
fragment(
|
|
||||||
"? @@ plainto_tsquery(?)",
|
|
||||||
o.fts_content,
|
|
||||||
^search_query
|
|
||||||
),
|
|
||||||
order_by: [fragment("? <=> now()::date", o.inserted_at)]
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp query_with(q, :rum, search_query, :websearch) do
|
|
||||||
from([a, o] in q,
|
from([a, o] in q,
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
|
@ -9,8 +9,6 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocation do
|
|||||||
"""
|
"""
|
||||||
@behaviour Pleroma.Upload.Filter
|
@behaviour Pleroma.Upload.Filter
|
||||||
|
|
||||||
@spec filter(Pleroma.Upload.t()) :: {:ok, any()} | {:error, String.t()}
|
|
||||||
|
|
||||||
# Formats not compatible with exiftool at this time
|
# Formats not compatible with exiftool at this time
|
||||||
def filter(%Pleroma.Upload{content_type: "image/heic"}), do: {:ok, :noop}
|
def filter(%Pleroma.Upload{content_type: "image/heic"}), do: {:ok, :noop}
|
||||||
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
|
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
|
||||||
|
@ -38,7 +38,6 @@ defmodule Pleroma.Upload.Filter.Mogrifun do
|
|||||||
[{"fill", "yellow"}, {"tint", "40"}]
|
[{"fill", "yellow"}, {"tint", "40"}]
|
||||||
]
|
]
|
||||||
|
|
||||||
@spec filter(Pleroma.Upload.t()) :: {:ok, atom()} | {:error, String.t()}
|
|
||||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||||
try do
|
try do
|
||||||
Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
|
Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
|
||||||
|
@ -8,7 +8,6 @@ defmodule Pleroma.Upload.Filter.Mogrify do
|
|||||||
@type conversion :: action :: String.t() | {action :: String.t(), opts :: String.t()}
|
@type conversion :: action :: String.t() | {action :: String.t(), opts :: String.t()}
|
||||||
@type conversions :: conversion() | [conversion()]
|
@type conversions :: conversion() | [conversion()]
|
||||||
|
|
||||||
@spec filter(Pleroma.Upload.t()) :: {:ok, :atom} | {:error, String.t()}
|
|
||||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||||
try do
|
try do
|
||||||
do_filter(file, Pleroma.Config.get!([__MODULE__, :args]))
|
do_filter(file, Pleroma.Config.get!([__MODULE__, :args]))
|
||||||
|
@ -2053,7 +2053,8 @@ defmodule Pleroma.User do
|
|||||||
%{scheme: scheme, userinfo: nil, host: host}
|
%{scheme: scheme, userinfo: nil, host: host}
|
||||||
when not_empty_string(host) and scheme in ["http", "https"] <-
|
when not_empty_string(host) and scheme in ["http", "https"] <-
|
||||||
URI.parse(value),
|
URI.parse(value),
|
||||||
{:not_idn, true} <- {:not_idn, to_string(:idna.encode(host)) == host},
|
{:not_idn, true} <-
|
||||||
|
{:not_idn, match?(^host, to_string(:idna.encode(to_charlist(host))))},
|
||||||
"me" <- Pleroma.Web.RelMe.maybe_put_rel_me(value, profile_urls) do
|
"me" <- Pleroma.Web.RelMe.maybe_put_rel_me(value, profile_urls) do
|
||||||
CommonUtils.to_masto_date(NaiveDateTime.utc_now())
|
CommonUtils.to_masto_date(NaiveDateTime.utc_now())
|
||||||
else
|
else
|
||||||
@ -2727,7 +2728,7 @@ defmodule Pleroma.User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec add_to_block(User.t(), User.t()) ::
|
@spec remove_from_block(User.t(), User.t()) ::
|
||||||
{:ok, UserRelationship.t()} | {:ok, nil} | {:error, Ecto.Changeset.t()}
|
{:ok, UserRelationship.t()} | {:ok, nil} | {:error, Ecto.Changeset.t()}
|
||||||
defp remove_from_block(%User{} = user, %User{} = blocked) do
|
defp remove_from_block(%User{} = user, %User{} = blocked) do
|
||||||
with {:ok, relationship} <- UserRelationship.delete_block(user, blocked) do
|
with {:ok, relationship} <- UserRelationship.delete_block(user, blocked) do
|
||||||
|
@ -103,7 +103,11 @@ defmodule Pleroma.Web.ActivityPub.MRF.DNSRBLPolicy do
|
|||||||
{:ok, object}
|
{:ok, object}
|
||||||
else
|
else
|
||||||
Task.start(fn ->
|
Task.start(fn ->
|
||||||
reason = rblquery(query, :txt) || "undefined"
|
reason =
|
||||||
|
case rblquery(query, :txt) do
|
||||||
|
[[result]] -> result
|
||||||
|
_ -> "undefined"
|
||||||
|
end
|
||||||
|
|
||||||
Logger.warning(
|
Logger.warning(
|
||||||
"DNSRBL Rejected activity from #{actor_host} for reason: #{inspect(reason)}"
|
"DNSRBL Rejected activity from #{actor_host} for reason: #{inspect(reason)}"
|
||||||
|
@ -96,7 +96,7 @@ defmodule Pleroma.Web.OAuth.Token do
|
|||||||
|> validate_required([:valid_until])
|
|> validate_required([:valid_until])
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec create(App.t(), User.t(), map()) :: {:ok, Token} | {:error, Ecto.Changeset.t()}
|
@spec create(App.t(), User.t(), map()) :: {:ok, Token.t()} | {:error, Ecto.Changeset.t()}
|
||||||
def create(%App{} = app, %User{} = user, attrs \\ %{}) do
|
def create(%App{} = app, %User{} = user, attrs \\ %{}) do
|
||||||
with {:ok, token} <- do_create(app, user, attrs) do
|
with {:ok, token} <- do_create(app, user, attrs) do
|
||||||
if Pleroma.Config.get([:oauth2, :clean_expired_tokens]) do
|
if Pleroma.Config.get([:oauth2, :clean_expired_tokens]) do
|
||||||
|
@ -63,6 +63,7 @@ defmodule Pleroma.Web.Push.Impl do
|
|||||||
|
|
||||||
@doc "Push message to web"
|
@doc "Push message to web"
|
||||||
def push_message(body, sub, api_key, subscription) do
|
def push_message(body, sub, api_key, subscription) do
|
||||||
|
try do
|
||||||
case WebPushEncryption.send_web_push(body, sub, api_key) do
|
case WebPushEncryption.send_web_push(body, sub, api_key) do
|
||||||
{:ok, %{status: code}} when code in 400..499 ->
|
{:ok, %{status: code}} when code in 400..499 ->
|
||||||
Logger.debug("Removing subscription record")
|
Logger.debug("Removing subscription record")
|
||||||
@ -76,6 +77,11 @@ defmodule Pleroma.Web.Push.Impl do
|
|||||||
Logger.error("Web Push Notification failed with code: #{code}")
|
Logger.error("Web Push Notification failed with code: #{code}")
|
||||||
:error
|
:error
|
||||||
|
|
||||||
|
error ->
|
||||||
|
Logger.error("Web Push Notification failed with #{inspect(error)}")
|
||||||
|
:error
|
||||||
|
end
|
||||||
|
rescue
|
||||||
error ->
|
error ->
|
||||||
Logger.error("Web Push Notification failed with #{inspect(error)}")
|
Logger.error("Web Push Notification failed with #{inspect(error)}")
|
||||||
:error
|
:error
|
||||||
|
Loading…
Reference in New Issue
Block a user