Remove doubled 'to' recipients.

This commit is contained in:
Roger Braun 2017-05-03 16:08:24 +02:00
parent 8141024259
commit df71c142cf
2 changed files with 8 additions and 1 deletions

View File

@ -24,7 +24,7 @@ def create(to, actor, context, object, additional \\ %{}, published \\ nil, loca
activity = %{ activity = %{
"type" => "Create", "type" => "Create",
"to" => to, "to" => to |> Enum.uniq,
"actor" => actor.ap_id, "actor" => actor.ap_id,
"object" => object, "object" => object,
"published" => published, "published" => published,

View File

@ -40,6 +40,13 @@ test "adds an id to a given object if it lacks one and inserts it to the object
end end
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 describe "fetch activities for recipients" do
test "retrieve the activities for certain recipients" do test "retrieve the activities for certain recipients" do
{:ok, activity_one} = ActivityBuilder.insert(%{"to" => ["someone"]}) {:ok, activity_one} = ActivityBuilder.insert(%{"to" => ["someone"]})