Improve the detection of a banner image.
- Also accept attachments of type Image - Prefer the key "image" if it is set as the banner image (https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object) - solves #1399 Co-authored-by: Thomas Citharel <tcit@tcit.fr> Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
committed by
Thomas Citharel
parent
fae480c24e
commit
0d7462de06
76
test/federation/activity_stream/converter/utils_test.exs
Normal file
76
test/federation/activity_stream/converter/utils_test.exs
Normal file
@@ -0,0 +1,76 @@
|
||||
defmodule Mobilizon.Federation.ActivityStream.Converter.UtilsTest do
|
||||
@moduledoc """
|
||||
Module to test converting from EventMetadata to AS
|
||||
"""
|
||||
use Mobilizon.DataCase
|
||||
import Mobilizon.Factory
|
||||
alias Mobilizon.Federation.ActivityStream.Converter.Utils
|
||||
|
||||
describe "get_medias/1" do
|
||||
test "getting banner from Document attachment" do
|
||||
data =
|
||||
File.read!("test/fixtures/mobilizon-post-activity-media.json")
|
||||
|> Jason.decode!()
|
||||
|> Map.get("object")
|
||||
|
||||
assert Utils.get_medias(data) ==
|
||||
{%{
|
||||
"blurhash" => "U5SY?Z00nOxu7ORP.8-pU^kVS#NGXyxbMxM{",
|
||||
"mediaType" => "image/png",
|
||||
"name" => nil,
|
||||
"type" => "Document",
|
||||
"url" => "https://mobilizon.fr/some-image"
|
||||
}, []}
|
||||
end
|
||||
|
||||
test "getting banner from image property" do
|
||||
data =
|
||||
File.read!("test/fixtures/mobilizon-post-activity-media-1.json")
|
||||
|> Jason.decode!()
|
||||
|> Map.get("object")
|
||||
|
||||
assert Utils.get_medias(data) ==
|
||||
{%{
|
||||
"blurhash" => "U5SY?Z00nOxu7ORP.8-pU^kVS#NGXyxbMxM{",
|
||||
"mediaType" => "image/png",
|
||||
"name" => nil,
|
||||
"type" => "Image",
|
||||
"url" => "https://mobilizon.fr/some-image-1"
|
||||
},
|
||||
[
|
||||
%{
|
||||
"blurhash" => "U5SY?Z00nOxu7ORP.8-pU^kVS#NGXyxbMxM{",
|
||||
"mediaType" => "image/png",
|
||||
"name" => nil,
|
||||
"type" => "Document",
|
||||
"url" => "https://mobilizon.fr/some-image"
|
||||
}
|
||||
]}
|
||||
end
|
||||
|
||||
test "getting banner from attachment named \"Banner\"" do
|
||||
data =
|
||||
File.read!("test/fixtures/mobilizon-post-activity-media-2.json")
|
||||
|> Jason.decode!()
|
||||
|> Map.get("object")
|
||||
|
||||
assert Utils.get_medias(data) ==
|
||||
{%{
|
||||
"blurhash" => "U5SY?Z00nOxu7ORP.8-pU^kVS#NGXyxbMxM{",
|
||||
"mediaType" => "image/png",
|
||||
"name" => "Banner",
|
||||
"type" => "Document",
|
||||
"url" => "https://mobilizon.fr/some-image-2"
|
||||
},
|
||||
[
|
||||
%{
|
||||
"blurhash" => "U5SY?Z00nOxu7ORP.8-pU^kVS#NGXyxbMxM{",
|
||||
"mediaType" => "image/png",
|
||||
"name" => nil,
|
||||
"type" => "Document",
|
||||
"url" => "https://mobilizon.fr/some-image-1"
|
||||
}
|
||||
]}
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user