diff options
author | lain <lain@soykaf.club> | 2019-01-20 13:00:46 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-01-20 13:00:46 +0100 |
commit | cf1f35a93a096311dee62ee5ac142a1bb3cfb844 (patch) | |
tree | 29b56df545f86b3bce1e70316ef85169b3ce4e42 /lib | |
parent | 2020f26040e8c3b76182c1a99e7ba310e2312eac (diff) | |
download | pleroma-cf1f35a93a096311dee62ee5ac142a1bb3cfb844.tar.gz |
Send delete event over Mastodon streaming api
Closes #116
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 20 | ||||
-rw-r--r-- | lib/pleroma/web/streamer.ex | 9 |
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 130c06028..0431d62af 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -92,7 +92,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do def stream_out(activity) do public = "https://www.w3.org/ns/activitystreams#Public" - if activity.data["type"] in ["Create", "Announce"] do + if activity.data["type"] in ["Create", "Announce", "Delete"] do Pleroma.Web.Streamer.stream("user", activity) Pleroma.Web.Streamer.stream("list", activity) @@ -103,16 +103,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do Pleroma.Web.Streamer.stream("public:local", activity) end - activity.data["object"] - |> Map.get("tag", []) - |> Enum.filter(fn tag -> is_bitstring(tag) end) - |> Enum.map(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end) + if activity.data["type"] in ["Create"] do + activity.data["object"] + |> Map.get("tag", []) + |> Enum.filter(fn tag -> is_bitstring(tag) end) + |> Enum.map(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end) - if activity.data["object"]["attachment"] != [] do - Pleroma.Web.Streamer.stream("public:media", activity) + if activity.data["object"]["attachment"] != [] do + Pleroma.Web.Streamer.stream("public:media", activity) - if activity.local do - Pleroma.Web.Streamer.stream("public:local:media", activity) + if activity.local do + Pleroma.Web.Streamer.stream("public:local:media", activity) + end end end else diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 3136b1b9d..978c77e57 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -205,6 +205,15 @@ defmodule Pleroma.Web.Streamer do end) end + def push_to_socket(topics, topic, %Activity{id: id, data: %{"type" => "Delete"}}) do + Enum.each(topics[topic] || [], fn socket -> + send( + socket.transport_pid, + {:text, %{event: "delete", payload: to_string(id)} |> Jason.encode!()} + ) + end) + end + def push_to_socket(topics, topic, item) do Enum.each(topics[topic] || [], fn socket -> # Get the current user so we have up-to-date blocks etc. |