projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'feature/new-user-routes' into 'develop'
[akkoma]
/
lib
/
pleroma
/
web
/
streamer.ex
diff --git
a/lib/pleroma/web/streamer.ex
b/lib/pleroma/web/streamer.ex
index 3065981571bf51f0d3584b491e76b035752c4800..e1eecba4d297547347b7eb0ec1bafc162792cc27 100644
(file)
--- a/
lib/pleroma/web/streamer.ex
+++ b/
lib/pleroma/web/streamer.ex
@@
-4,17
+4,9
@@
defmodule Pleroma.Web.Streamer do
alias Pleroma.{User, Notification, Activity, Object, Repo}
alias Pleroma.Web.ActivityPub.ActivityPub
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
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.start_link(__MODULE__, %{}, name: __MODULE__)
end
@@
-30,6
+22,16
@@
defmodule Pleroma.Web.Streamer do
GenServer.cast(__MODULE__, %{action: :stream, topic: topic, item: item})
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()
def handle_cast(%{action: :ping}, topics) do
Map.values(topics)
|> List.flatten()
@@
-40,7
+42,7
@@
defmodule Pleroma.Web.Streamer do
spawn(fn ->
# 30 seconds
spawn(fn ->
# 30 seconds
- Process.sleep(
1000 * 30
)
+ Process.sleep(
@keepalive_interval
)
GenServer.cast(__MODULE__, %{action: :ping})
end)
GenServer.cast(__MODULE__, %{action: :ping})
end)
@@
-61,8
+63,6
@@
defmodule Pleroma.Web.Streamer do
end
def handle_cast(%{action: :stream, topic: "list", item: item}, topics) do
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
# filter the recipient list if the activity is not public, see #270.
recipient_lists =
case ActivityPub.is_public?(item) do
@@
-188,7
+188,7
@@
defmodule Pleroma.Web.Streamer do
# 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)
# 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"])
parent = Object.normalize(item.data["object"])
@@
-206,7
+206,7
@@
defmodule Pleroma.Web.Streamer do
# 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)
# 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)})
unless item.actor in blocks do
send(socket.transport_pid, {:text, represent_update(item, user)})