From 5ff5d583b69a1f68231b274de879826704d434f0 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 19 Nov 2017 13:47:50 +0100 Subject: [PATCH] MastodonAPI: Streaming fixes. Now shows repeats in the home tl. --- lib/pleroma/web/activity_pub/activity_pub.ex | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 4aade6e40..421fd5cd7 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -10,6 +10,7 @@ def insert(map, local \\ true) when is_map(map) do :ok <- insert_full_object(map) do {:ok, activity} = Repo.insert(%Activity{data: map, local: local, actor: map["actor"]}) Notification.create_notifications(activity) + stream_out(activity) {:ok, activity} else %Activity{} = activity -> {:ok, activity} @@ -17,17 +18,22 @@ def insert(map, local \\ true) when is_map(map) do end end + def stream_out(activity) do + if activity.data["type"] in ["Create", "Announce"] do + Pleroma.Web.Streamer.stream("user", activity) + if Enum.member?(activity.data["to"], "https://www.w3.org/ns/activitystreams#Public") do + Pleroma.Web.Streamer.stream("public", activity) + if activity.local do + Pleroma.Web.Streamer.stream("public:local", activity) + end + end + end + end + def create(to, actor, context, object, additional \\ %{}, published \\ nil, local \\ true) do with create_data <- make_create_data(%{to: to, actor: actor, published: published, context: context, object: object}, additional), {:ok, activity} <- insert(create_data, local), :ok <- maybe_federate(activity) do - if activity.data["type"] == "Create" and Enum.member?(activity.data["to"], "https://www.w3.org/ns/activitystreams#Public") do - Pleroma.Web.Streamer.stream("public", activity) - Pleroma.Web.Streamer.stream("user", activity) - if local do - Pleroma.Web.Streamer.stream("public:local", activity) - end - end {:ok, activity} end end