Only search in public data for now.
authorlain <lain@soykaf.club>
Sat, 7 Apr 2018 14:40:03 +0000 (16:40 +0200)
committerlain <lain@soykaf.club>
Sat, 7 Apr 2018 14:40:45 +0000 (16:40 +0200)
This should be the data the user is allowed to see later, but this
will stop accidental private message leaks.

lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/twitter_api/twitter_api.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index ccba4710a7fe99579af3482ccbdd354ec03d5062..6339704a25061682b64cda71f6c4ac0e53572a1f 100644 (file)
@@ -507,6 +507,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       from(
         a in Activity,
         where: fragment("?->>'type' = 'Create'", a.data),
+        where: "https://www.w3.org/ns/activitystreams#Public" in a.recipients,
         where:
           fragment(
             "to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)",
index 027b97154ed542c5421e837a6628cbffd167d9e1..c12cd7f8aa14a8912e89b69e04609a9e31897b38 100644 (file)
@@ -193,6 +193,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
       from(
         a in Activity,
         where: fragment("?->>'type' = 'Create'", a.data),
+        where: "https://www.w3.org/ns/activitystreams#Public" in a.recipients,
         where:
           fragment(
             "to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)",
index 2c9cdd194e9ba93ee630965319843c1d992054d2..5d39c25c617540f32719e80ea894989efbb42628 100644 (file)
@@ -564,6 +564,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
     user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
 
     {:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
+
+    {:ok, _activity} =
+      CommonAPI.post(user, %{
+        "status" => "This is about 2hu, but private",
+        "visibility" => "private"
+      })
+
     {:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
 
     conn =