Federation fixes

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-19 17:40:42 +01:00
parent fbf2d480a3
commit d7fd30f8e6
10 changed files with 53 additions and 250 deletions

View File

@@ -119,7 +119,7 @@ defmodule Mobilizon.Federation.ActivityPub.TransmogrifierTest do
assert object["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
assert object["cc"] == []
# assert object["cc"] == []
assert object["actor"] == "https://demo.gancio.org/federation/u/gancio"
assert object["location"]["name"] == "Colosseo"
@@ -146,11 +146,14 @@ defmodule Mobilizon.Federation.ActivityPub.TransmogrifierTest do
preferred_username: "member"
)
relay = Relay.get_actor()
with_mock ActivityPubActor, [:passthrough],
get_or_fetch_actor_by_url: fn url ->
case url do
^group_url -> {:ok, group}
^actor_url -> {:ok, actor}
"https://www.w3.org/ns/activitystreams#Public" -> {:ok, relay}
end
end do
data = File.read!("test/fixtures/mobilizon-post-activity-group.json") |> Jason.decode!()

View File

@@ -37,7 +37,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"attachment" => [],
"attributedTo" => ^actor_url,
"category" => nil,
"cc" => [],
"cc" => [^followers_url],
"commentsEnabled" => false,
"content" => nil,
"draft" => false,
@@ -108,7 +108,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
end
test "from a group member" do
%Actor{id: organizer_actor_id, url: actor_url} = actor = insert(:actor)
%Actor{id: organizer_actor_id, url: actor_url, followers_url: actor_followers_url} =
actor = insert(:actor)
%Actor{
id: attributed_to_id,
@@ -139,7 +140,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"attachment" => [],
"attributedTo" => ^group_url,
"category" => nil,
"cc" => [],
"cc" => [^actor_followers_url],
"commentsEnabled" => false,
"content" => nil,
"draft" => false,
@@ -189,7 +190,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"actor" => ^actor_url,
"anonymousParticipationEnabled" => false,
"attributedTo" => ^actor_url,
"cc" => [],
"cc" => [^followers_url],
"commentsEnabled" => false,
"draft" => false,
"ical:status" => "CONFIRMED",
@@ -212,7 +213,9 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
test "from a group member" do
%Actor{} = actor_1 = insert(:actor)
%Actor{id: organizer_actor_2_id, url: actor_2_url} = actor_2 = insert(:actor)
%Actor{id: organizer_actor_2_id, url: actor_2_url, followers_url: actor_followers_url} =
actor_2 = insert(:actor)
%Actor{
url: group_url,
@@ -247,7 +250,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"actor" => ^actor_2_url,
"anonymousParticipationEnabled" => false,
"attributedTo" => ^group_url,
"cc" => [],
"cc" => [^actor_followers_url],
"commentsEnabled" => false,
"draft" => false,
"ical:status" => "CONFIRMED",
@@ -269,7 +272,9 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
end
test "from a remote group member" do
%Actor{id: organizer_actor_1_id, url: actor_1_url} = actor_1 = insert(:actor)
%Actor{id: organizer_actor_1_id, url: actor_1_url, followers_url: actor_followers_url} =
actor_1 = insert(:actor)
%Actor{} = actor_2 = insert(:actor)
%Actor{
@@ -305,7 +310,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"actor" => ^actor_1_url,
"anonymousParticipationEnabled" => false,
"attributedTo" => ^group_url,
"cc" => [],
"cc" => [^actor_followers_url],
"commentsEnabled" => false,
"draft" => false,
"ical:status" => "CONFIRMED",