Commit b050d27c authored by kaniini's avatar kaniini

Merge branch 'bugfix/content_nil_lenght_check' into 'develop'

Web.ActivityPub.ActivityPub: Fix check_remote_limit/1 against activities with content: nil

See merge request pleroma/pleroma!711
parents 6383fa3a 499a4591
Pipeline #6580 passed with stages
in 5 minutes and 45 seconds
...@@ -64,7 +64,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do ...@@ -64,7 +64,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end end
end end
defp check_remote_limit(%{"object" => %{"content" => content}}) do defp check_remote_limit(%{"object" => %{"content" => content}}) when not is_nil(content) do
limit = Pleroma.Config.get([:instance, :remote_limit]) limit = Pleroma.Config.get([:instance, :remote_limit])
String.length(content) <= limit String.length(content) <= limit
end end
......
...@@ -85,6 +85,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do ...@@ -85,6 +85,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert {:error, {:remote_limit_error, _}} = ActivityPub.insert(data) assert {:error, {:remote_limit_error, _}} = ActivityPub.insert(data)
end end
test "doesn't drop activities with content being null" do
data = %{
"ok" => true,
"object" => %{
"content" => nil
}
}
assert {:ok, _} = ActivityPub.insert(data)
end
test "returns the activity if one with the same id is already in" do test "returns the activity if one with the same id is already in" do
activity = insert(:note_activity) activity = insert(:note_activity)
{:ok, new_activity} = ActivityPub.insert(activity.data) {:ok, new_activity} = ActivityPub.insert(activity.data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment