Remove doubled 'to' recipients.
authorRoger Braun <roger@rogerbraun.net>
Wed, 3 May 2017 14:08:24 +0000 (16:08 +0200)
committerRoger Braun <roger@rogerbraun.net>
Wed, 3 May 2017 14:08:24 +0000 (16:08 +0200)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs

index 194a5ec3d150d5a752ff9754c0dfd2c96c77c203..f18f3df2e780b50fedf9942cf285809c2d4e7d72 100644 (file)
@@ -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,
index 6e42fbda278adca6db52484904751a38e3c46bf7..dfa73b775bde52c338a8c92e1727b9aa81f32945 100644 (file)
@@ -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"]})