Fix conversations.
authorlain <lain@soykaf.club>
Sun, 18 Feb 2018 19:52:07 +0000 (20:52 +0100)
committerlain <lain@soykaf.club>
Sun, 18 Feb 2018 19:52:07 +0000 (20:52 +0100)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/twitter_api/twitter_api.ex

index 4bfcd32346462a0654655f5ada15bf7d5c4d0a30..fb33f2e3ef2eddfc6e637fab797673acc3d0a443 100644 (file)
@@ -129,12 +129,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   end
 
   def fetch_activities_for_context(context, opts \\ %{}) do
-    query = from activity in Activity,
-      where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
-      order_by: [desc: :id]
+    public = ["https://www.w3.org/ns/activitystreams#Public"]
+    recipients = if opts["user"], do: [opts["user"].ap_id | opts["user"].following] ++ public, else: public
+
+    query = from activity in Activity
     query = query
       |> restrict_blocked(opts)
-      |> restrict_recipients(["https://www.w3.org/ns/activitystreams#Public"], opts["user"])
+      |> restrict_recipients(recipients, opts["user"])
+
+   query = from activity in query,
+      where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
+      order_by: [desc: :id]
     Repo.all(query)
   end
 
index 174a794846dd89ffffe1f12c7c122d9dfc5dd727..411c2f812341fc5863d03241bc5319a318ab3d30 100644 (file)
@@ -46,7 +46,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
 
   def fetch_conversation(user, id) do
     with context when is_binary(context) <- conversation_id_to_context(id),
-         activities <- ActivityPub.fetch_activities_for_context(context, %{"blocking_user" => user}),
+         activities <- ActivityPub.fetch_activities_for_context(context, %{"blocking_user" => user, "user" => user}),
          statuses <- activities |> activities_to_statuses(%{for: user})
     do
       statuses