Support objects with a nil contentMap (firefish)
Closes: https://git.pleroma.social/pleroma/pleroma/-/issues/3231
This commit is contained in:
parent
67a5542a73
commit
7651198508
|
@ -0,0 +1 @@
|
||||||
|
Support objects with a null contentMap (firefish)
|
|
@ -339,6 +339,10 @@ def fix_tag(%{"tag" => %{} = tag} = object) do
|
||||||
|
|
||||||
def fix_tag(object), do: object
|
def fix_tag(object), do: object
|
||||||
|
|
||||||
|
def fix_content_map(%{"contentMap" => nil} = object) do
|
||||||
|
Map.drop(object, ["contentMap"])
|
||||||
|
end
|
||||||
|
|
||||||
# content map usually only has one language so this will do for now.
|
# content map usually only has one language so this will do for now.
|
||||||
def fix_content_map(%{"contentMap" => content_map} = object) do
|
def fix_content_map(%{"contentMap" => content_map} = object) do
|
||||||
content_groups = Map.to_list(content_map)
|
content_groups = Map.to_list(content_map)
|
||||||
|
|
|
@ -221,6 +221,19 @@ test "it works for incoming notices with contentMap" do
|
||||||
"<p><span class=\"h-card\"><a href=\"http://localtesting.pleroma.lol/users/lain\" class=\"u-url mention\">@<span>lain</span></a></span></p>"
|
"<p><span class=\"h-card\"><a href=\"http://localtesting.pleroma.lol/users/lain\" class=\"u-url mention\">@<span>lain</span></a></span></p>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it works for incoming notices with a nil contentMap (firefish)" do
|
||||||
|
data =
|
||||||
|
File.read!("test/fixtures/mastodon-post-activity-contentmap.json")
|
||||||
|
|> Jason.decode!()
|
||||||
|
|> Map.put("contentMap", nil)
|
||||||
|
|
||||||
|
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||||
|
object = Object.normalize(data["object"], fetch: false)
|
||||||
|
|
||||||
|
assert object.data["content"] ==
|
||||||
|
"<p><span class=\"h-card\"><a href=\"http://localtesting.pleroma.lol/users/lain\" class=\"u-url mention\">@<span>lain</span></a></span></p>"
|
||||||
|
end
|
||||||
|
|
||||||
test "it works for incoming notices with to/cc not being an array (kroeg)" do
|
test "it works for incoming notices with to/cc not being an array (kroeg)" do
|
||||||
data = File.read!("test/fixtures/kroeg-post-activity.json") |> Jason.decode!()
|
data = File.read!("test/fixtures/kroeg-post-activity.json") |> Jason.decode!()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue