summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-11-30 10:41:18 +0000
committerrinpatch <rinpatch@sdf.org>2019-11-30 10:41:18 +0000
commitcf0c861d0012f27ae555247834187d509d7a7114 (patch)
tree369c00656ea4f6d40864f3fe5483fbe6c749e5ab
parentb21738d4c08b2f0d66944e3f74a15f3a3985b37a (diff)
parent1915b23e72c5cbed5c794f66eb0a727e719d3c57 (diff)
downloadpleroma-cf0c861d0012f27ae555247834187d509d7a7114.tar.gz
pleroma-cf0c861d0012f27ae555247834187d509d7a7114.zip
Merge branch 'hide-relation-for-friendica' into 'develop'
Hide relation for friendica users See merge request pleroma/pleroma!2026
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex10
-rw-r--r--test/fixtures/users_mock/friendica_followers.json19
-rw-r--r--test/fixtures/users_mock/friendica_following.json19
-rw-r--r--test/support/http_request_mock.ex16
-rw-r--r--test/web/activity_pub/activity_pub_test.exs15
5 files changed, 75 insertions, 4 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index f25314ff6..f32d04175 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -1233,13 +1233,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
end
- defp collection_private(data) do
- if is_map(data["first"]) and
- data["first"]["type"] in ["CollectionPage", "OrderedCollectionPage"] do
+ defp collection_private(%{"first" => first}) do
+ if is_map(first) and
+ first["type"] in ["CollectionPage", "OrderedCollectionPage"] do
{:ok, false}
else
with {:ok, %{"type" => type}} when type in ["CollectionPage", "OrderedCollectionPage"] <-
- Fetcher.fetch_and_contain_remote_object_from_id(data["first"]) do
+ Fetcher.fetch_and_contain_remote_object_from_id(first) do
{:ok, false}
else
{:error, {:ok, %{status: code}}} when code in [401, 403] ->
@@ -1254,6 +1254,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
end
+ defp collection_private(_data), do: {:ok, true}
+
def user_data_from_user_object(data) do
with {:ok, data} <- MRF.filter(data),
{:ok, data} <- object_to_user_data(data) do
diff --git a/test/fixtures/users_mock/friendica_followers.json b/test/fixtures/users_mock/friendica_followers.json
new file mode 100644
index 000000000..7b86b5fe2
--- /dev/null
+++ b/test/fixtures/users_mock/friendica_followers.json
@@ -0,0 +1,19 @@
+{
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ {
+ "vcard": "http://www.w3.org/2006/vcard/ns#",
+ "dfrn": "http://purl.org/macgirvin/dfrn/1.0/",
+ "diaspora": "https://diasporafoundation.org/ns/",
+ "litepub": "http://litepub.social/ns#",
+ "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
+ "sensitive": "as:sensitive",
+ "Hashtag": "as:Hashtag",
+ "directMessage": "litepub:directMessage"
+ }
+ ],
+ "id": "http://localhost:8080/followers/fuser3",
+ "type": "OrderedCollection",
+ "totalItems": 296
+}
diff --git a/test/fixtures/users_mock/friendica_following.json b/test/fixtures/users_mock/friendica_following.json
new file mode 100644
index 000000000..7c526befc
--- /dev/null
+++ b/test/fixtures/users_mock/friendica_following.json
@@ -0,0 +1,19 @@
+{
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ {
+ "vcard": "http://www.w3.org/2006/vcard/ns#",
+ "dfrn": "http://purl.org/macgirvin/dfrn/1.0/",
+ "diaspora": "https://diasporafoundation.org/ns/",
+ "litepub": "http://litepub.social/ns#",
+ "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
+ "sensitive": "as:sensitive",
+ "Hashtag": "as:Hashtag",
+ "directMessage": "litepub:directMessage"
+ }
+ ],
+ "id": "http://localhost:8080/following/fuser3",
+ "type": "OrderedCollection",
+ "totalItems": 32
+}
diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex
index 965335e96..e3a621f49 100644
--- a/test/support/http_request_mock.ex
+++ b/test/support/http_request_mock.ex
@@ -1035,6 +1035,22 @@ defmodule HttpRequestMock do
}}
end
+ def get("http://localhost:8080/followers/fuser3", _, _, _) do
+ {:ok,
+ %Tesla.Env{
+ status: 200,
+ body: File.read!("test/fixtures/users_mock/friendica_followers.json")
+ }}
+ end
+
+ def get("http://localhost:8080/following/fuser3", _, _, _) do
+ {:ok,
+ %Tesla.Env{
+ status: 200,
+ body: File.read!("test/fixtures/users_mock/friendica_following.json")
+ }}
+ end
+
def get("http://localhost:4001/users/fuser2/followers", _, _, _) do
{:ok,
%Tesla.Env{
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index d437ad456..30f5dde0c 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -1554,5 +1554,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert follow_info.hide_followers == false
assert follow_info.hide_follows == true
end
+
+ test "detects hidden follows/followers for friendica" do
+ user =
+ insert(:user,
+ local: false,
+ follower_address: "http://localhost:8080/followers/fuser3",
+ following_address: "http://localhost:8080/following/fuser3"
+ )
+
+ {:ok, follow_info} = ActivityPub.fetch_follow_information_for_user(user)
+ assert follow_info.hide_followers == true
+ assert follow_info.follower_count == 296
+ assert follow_info.following_count == 32
+ assert follow_info.hide_follows == true
+ end
end
end