+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Web.Streamer do
use GenServer
require Logger
alias Pleroma.{User, Notification, Activity, Object, Repo}
alias Pleroma.Web.ActivityPub.ActivityPub
- def init(args) do
- {:ok, args}
- end
+ @keepalive_interval :timer.seconds(30)
def start_link do
- spawn(fn ->
- # 30 seconds
- Process.sleep(1000 * 30)
- GenServer.cast(__MODULE__, %{action: :ping})
- end)
-
GenServer.start_link(__MODULE__, %{}, name: __MODULE__)
end
GenServer.cast(__MODULE__, %{action: :stream, topic: topic, item: item})
end
+ def init(args) do
+ spawn(fn ->
+ # 30 seconds
+ Process.sleep(@keepalive_interval)
+ GenServer.cast(__MODULE__, %{action: :ping})
+ end)
+
+ {:ok, args}
+ end
+
def handle_cast(%{action: :ping}, topics) do
Map.values(topics)
|> List.flatten()
spawn(fn ->
# 30 seconds
- Process.sleep(1000 * 30)
+ Process.sleep(@keepalive_interval)
GenServer.cast(__MODULE__, %{action: :ping})
end)
end
def handle_cast(%{action: :stream, topic: "list", item: item}, topics) do
- author = User.get_cached_by_ap_id(item.data["actor"])
-
# filter the recipient list if the activity is not public, see #270.
recipient_lists =
case ActivityPub.is_public?(item) do