logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 06b8923d4222b617aeeffd507aa2bf7aa5943de1
parent 28af5e3bd7073980465c1f6c1b2f6019c4a45e4f
Author: Mark Felder <feld@feld.me>
Date:   Fri, 26 Jan 2024 17:37:32 -0500

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()}

Diffstat:

Mlib/pleroma/web/rich_media/parser.ex2+-
Mlib/pleroma/web/rich_media/parser/ttl/aws_signed_url.ex2+-
Mtest/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs2+-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex @@ -105,7 +105,7 @@ defmodule Pleroma.Web.RichMedia.Parser do {:ok, integer() | :noop} | {:error, :no_key} def set_ttl_based_on_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 case @cachex.expire_at(:rich_media_cache, url, ttl) do diff --git a/lib/pleroma/web/rich_media/parser/ttl/aws_signed_url.ex b/lib/pleroma/web/rich_media/parser/ttl/aws_signed_url.ex @@ -45,6 +45,6 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl do |> Map.get("X-Amz-Date") |> 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 diff --git a/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs b/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs @@ -22,7 +22,7 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrlTest do expire_time = 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 test "s3 signed url is parsed and correct ttl is set for rich media" do