From df71c142cfadaae8866303768bca00c343b8bed1 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 3 May 2017 16:08:24 +0200 Subject: [PATCH] Remove doubled 'to' recipients. --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- test/web/activity_pub/activity_pub_test.exs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 194a5ec3d..f18f3df2e 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -24,7 +24,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do activity = %{ "type" => "Create", - "to" => to, + "to" => to |> Enum.uniq, "actor" => actor.ap_id, "object" => object, "published" => published, diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 6e42fbda2..dfa73b775 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -40,6 +40,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end end + describe "create activities" do + test "removes doubled 'to' recipients" do + {:ok, activity} = ActivityPub.create(["user1", "user1", "user2"], %User{ap_id: "1"}, "", %{}) + assert activity.data["to"] == ["user1", "user2"] + end + end + describe "fetch activities for recipients" do test "retrieve the activities for certain recipients" do {:ok, activity_one} = ActivityBuilder.insert(%{"to" => ["someone"]}) -- 2.45.2