Add SetMeta filter to store uploaded image sizes

This commit is contained in:
Alex Gleason 2021-05-12 13:38:11 -05:00
commit ab9eabdf20
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 83 additions and 2 deletions

View file

@ -0,0 +1,19 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Upload.Filter.SetMetaTest do
use Pleroma.DataCase, async: true
alias Pleroma.Upload.Filter.SetMeta
test "adds the image dimensions" do
upload = %Pleroma.Upload{
name: "an… image.jpg",
content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
tempfile: Path.absname("test/fixtures/image.jpg")
}
assert {:ok, :filtered, %{width: 1024, height: 768}} = SetMeta.filter(upload)
end
end

View file

@ -458,7 +458,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
"url" => [
%{
"mediaType" => "image/png",
"href" => "someurl"
"href" => "someurl",
"width" => 200,
"height" => 100
}
],
"blurhash" => "UJJ8X[xYW,%Jtq%NNFbXB5j]IVM|9GV=WHRn",
@ -474,6 +476,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
text_url: "someurl",
description: nil,
pleroma: %{mime_type: "image/png"},
meta: %{original: %{width: 200, height: 100, aspect: 2}},
blurhash: "UJJ8X[xYW,%Jtq%NNFbXB5j]IVM|9GV=WHRn"
}