From 15aa45ae8a2791a90a5832c1be28233959690987 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 26 Jan 2019 03:50:49 +0100 Subject: [PATCH 1/2] Web.ActivityPub.ActivityPub: Fix check_remote_limit/1 against activities with content: nil --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 6b4682e35..07779fa00 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -64,7 +64,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do 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]) String.length(content) <= limit end From 499a4591a4689094bff597e30ce599a6fc189ea3 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 26 Jan 2019 04:23:52 +0100 Subject: [PATCH 2/2] Web.ActivityPub.ActivityPubTest: test against inserting activities with content: null --- test/web/activity_pub/activity_pub_test.exs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index d2e54d804..91548ab5f 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -85,6 +85,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert {:error, {:remote_limit_error, _}} = ActivityPub.insert(data) 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 activity = insert(:note_activity) {:ok, new_activity} = ActivityPub.insert(activity.data)