summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2024-06-08 17:55:01 +0000
committerfeld <feld@feld.me>2024-06-08 17:55:01 +0000
commit9d67827619e7f770d7dd6cea98ad33f5cfa33991 (patch)
tree239c66ad5a60368bdc83727488d7f6081e2654e5 /lib
parentc24e222887808ea7e2080ad54dea340212a5e9df (diff)
parent471412ad34e87106641101c9e9e44fb1df2ca905 (diff)
downloadpleroma-9d67827619e7f770d7dd6cea98ad33f5cfa33991.tar.gz
pleroma-9d67827619e7f770d7dd6cea98ad33f5cfa33991.zip
Merge branch 'stream-poll-end' into 'develop'
Stream end of poll notification over websockets and web push See merge request pleroma/pleroma!4137
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex7
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex2
-rw-r--r--lib/pleroma/web/activity_pub/side_effects.ex6
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index f521a2998..b9694a353 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -479,6 +479,8 @@ defmodule Pleroma.Notification do
end
end)
+ stream(notifications)
+
{:ok, notifications}
end
end
@@ -757,8 +759,9 @@ defmodule Pleroma.Notification do
|> Repo.update_all(set: [seen: true])
end
- @spec send(list(Notification.t())) :: :ok
- def send(notifications) do
+ @doc "Streams a list of notifications over websockets and web push"
+ @spec stream(list(Notification.t())) :: :ok
+ def stream(notifications) do
Enum.each(notifications, fn notification ->
Streamer.stream(["user", "user:notification"], notification)
Push.send(notification)
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 1247ae7ce..6c1d6ded9 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -201,7 +201,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
def notify_and_stream(activity) do
{:ok, notifications} = Notification.create_notifications(activity)
- Notification.send(notifications)
+ Notification.stream(notifications)
original_activity =
case activity do
diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex
index 60b4d5f1b..2a141b0f5 100644
--- a/lib/pleroma/web/activity_pub/side_effects.ex
+++ b/lib/pleroma/web/activity_pub/side_effects.ex
@@ -592,9 +592,9 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
with {:ok, _} <- Repo.delete(object), do: :ok
end
- defp send_notifications(meta) do
+ defp stream_notifications(meta) do
Keyword.get(meta, :notifications, [])
- |> Notification.send()
+ |> Notification.stream()
meta
end
@@ -625,7 +625,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
@impl true
def handle_after_transaction(meta) do
meta
- |> send_notifications()
+ |> stream_notifications()
|> send_streamables()
end
end