Merge branch 'fix-remote-actor-visibility' into 'master'
Fix remote group visibility and use Mastodon's discoverable attribute Closes #370 See merge request framasoft/mobilizon!537
This commit is contained in:
commit
647b8402d0
@ -39,6 +39,9 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
|
|||||||
"sc" => "http://schema.org#",
|
"sc" => "http://schema.org#",
|
||||||
"ical" => "http://www.w3.org/2002/12/cal/ical#",
|
"ical" => "http://www.w3.org/2002/12/cal/ical#",
|
||||||
"pt" => "https://joinpeertube.org/ns#",
|
"pt" => "https://joinpeertube.org/ns#",
|
||||||
|
"toot" => "http://joinmastodon.org/ns#",
|
||||||
|
"discoverable" => "toot:discoverable",
|
||||||
|
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
|
||||||
"Hashtag" => "as:Hashtag",
|
"Hashtag" => "as:Hashtag",
|
||||||
"category" => "sc:category",
|
"category" => "sc:category",
|
||||||
"uuid" => "sc:identifier",
|
"uuid" => "sc:identifier",
|
||||||
|
@ -64,7 +64,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Actor do
|
|||||||
shared_inbox_url: data["endpoints"]["sharedInbox"],
|
shared_inbox_url: data["endpoints"]["sharedInbox"],
|
||||||
domain: URI.parse(data["id"]).host,
|
domain: URI.parse(data["id"]).host,
|
||||||
manually_approves_followers: data["manuallyApprovesFollowers"],
|
manually_approves_followers: data["manuallyApprovesFollowers"],
|
||||||
type: data["type"]
|
type: data["type"],
|
||||||
|
visibility: if(Map.get(data, "discoverable", false) == true, do: :public, else: :unlisted)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Actor do
|
|||||||
"endpoints" => %{
|
"endpoints" => %{
|
||||||
"sharedInbox" => actor.shared_inbox_url
|
"sharedInbox" => actor.shared_inbox_url
|
||||||
},
|
},
|
||||||
|
"discoverable" => actor.visibility == :public,
|
||||||
"manuallyApprovesFollowers" => actor.manually_approves_followers,
|
"manuallyApprovesFollowers" => actor.manually_approves_followers,
|
||||||
"publicKey" => %{
|
"publicKey" => %{
|
||||||
"id" => "#{actor.url}#main-key",
|
"id" => "#{actor.url}#main-key",
|
||||||
|
@ -43,8 +43,15 @@ defmodule Mobilizon.Federation.ActivityPubTest do
|
|||||||
describe "fetching actor from its url" do
|
describe "fetching actor from its url" do
|
||||||
test "returns an actor from nickname" do
|
test "returns an actor from nickname" do
|
||||||
use_cassette "activity_pub/fetch_tcit@framapiaf.org" do
|
use_cassette "activity_pub/fetch_tcit@framapiaf.org" do
|
||||||
assert {:ok, %Actor{preferred_username: "tcit", domain: "framapiaf.org"} = actor} =
|
assert {:ok,
|
||||||
ActivityPub.make_actor_from_nickname("tcit@framapiaf.org")
|
%Actor{preferred_username: "tcit", domain: "framapiaf.org", visibility: :public} =
|
||||||
|
actor} = ActivityPub.make_actor_from_nickname("tcit@framapiaf.org")
|
||||||
|
end
|
||||||
|
|
||||||
|
use_cassette "activity_pub/fetch_tcit@framapiaf.org_not_discoverable" do
|
||||||
|
assert {:ok,
|
||||||
|
%Actor{preferred_username: "tcit", domain: "framapiaf.org", visibility: :unlisted} =
|
||||||
|
actor} = ActivityPub.make_actor_from_nickname("tcit@framapiaf.org")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -52,7 +59,9 @@ defmodule Mobilizon.Federation.ActivityPubTest do
|
|||||||
test "returns an actor from url" do
|
test "returns an actor from url" do
|
||||||
# Initial fetch
|
# Initial fetch
|
||||||
use_cassette "activity_pub/fetch_framapiaf.org_users_tcit" do
|
use_cassette "activity_pub/fetch_framapiaf.org_users_tcit" do
|
||||||
assert {:ok, %Actor{preferred_username: "tcit", domain: "framapiaf.org"}} =
|
# Unlisted because discoverable is not present in the JSON payload
|
||||||
|
assert {:ok,
|
||||||
|
%Actor{preferred_username: "tcit", domain: "framapiaf.org", visibility: :unlisted}} =
|
||||||
ActivityPub.get_or_fetch_actor_by_url(@actor_url)
|
ActivityPub.get_or_fetch_actor_by_url(@actor_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
79
test/fixtures/vcr_cassettes/activity_pub/fetch_tcit@framapiaf.org_not_discoverable.json
vendored
Normal file
79
test/fixtures/vcr_cassettes/activity_pub/fetch_tcit@framapiaf.org_not_discoverable.json
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user