From 010f818a29d813e912cc38b3bdc259bed9837ed9 Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 18 Feb 2018 20:52:07 +0100 Subject: [PATCH] Fix conversations. --- lib/pleroma/web/activity_pub/activity_pub.ex | 13 +++++++++---- lib/pleroma/web/twitter_api/twitter_api.ex | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 4bfcd3234..fb33f2e3e 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -129,12 +129,17 @@ def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ tru 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 diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 174a79484..411c2f812 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -46,7 +46,7 @@ def fetch_mentions(user, opts \\ %{}) 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