RichMedia.Parser.TTL.AwsSignedUrl: dialyzer fix

lib/pleroma/web/rich_media/parser/ttl/aws_signed_url.ex:9:callback_type_mismatch
Type mismatch for @callback ttl/2 in Pleroma.Web.RichMedia.Parser.TTL behaviour.

Expected type:
nil | integer()

Actual type:
{:error, <<_::64, _::size(8)>>} | {:ok, integer()}
This commit is contained in:
Mark Felder 2024-01-26 17:37:32 -05:00
parent 28af5e3bd7
commit 06b8923d42
3 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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