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
Pleroma.List.get_lists_from_activity(item)
|> Enum.filter(fn list ->
owner = Repo.get(User, list.user_id)
- author.follower_address in owner.following
+
+ ActivityPub.visible_for_user?(item, owner)
end)
end
# Get the current user so we have up-to-date blocks etc.
if socket.assigns[:user] do
user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id)
- blocks = user.info["blocks"] || []
+ blocks = user.info.blocks || []
parent = Object.normalize(item.data["object"])
# Get the current user so we have up-to-date blocks etc.
if socket.assigns[:user] do
user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id)
- blocks = user.info["blocks"] || []
+ blocks = user.info.blocks || []
unless item.actor in blocks do
send(socket.transport_pid, {:text, represent_update(item, user)})