From b670d4d683b66bc41dc11e230e3070eb7171b144 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 17 Jun 2018 15:01:27 +0200 Subject: [PATCH] MastodonAPI: Add streaming to media tabs of federated and local TLs --- lib/pleroma/web/activity_pub/activity_pub.ex | 8 ++++++++ lib/pleroma/web/mastodon_api/mastodon_socket.ex | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 267427a23..554202f6b 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -65,6 +65,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do if activity.local do Pleroma.Web.Streamer.stream("public:local", activity) end + + 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) + end + end else if !Enum.member?(activity.data["cc"] || [], public) && !Enum.member?( diff --git a/lib/pleroma/web/mastodon_api/mastodon_socket.ex b/lib/pleroma/web/mastodon_api/mastodon_socket.ex index 46648c366..174293906 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_socket.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_socket.ex @@ -15,8 +15,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonSocket do with token when not is_nil(token) <- params["access_token"], %Token{user_id: user_id} <- Repo.get_by(Token, token: token), %User{} = user <- Repo.get(User, user_id), - stream when stream in ["public", "public:local", "user", "direct", "list"] <- - params["stream"] do + stream + when stream in [ + "public", + "public:local", + "public:media", + "public:local:media", + "user", + "direct", + "list" + ] <- params["stream"] do topic = if stream == "list", do: "list:#{params["list"]}", else: stream socket = -- 2.45.2