summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2024-06-11 18:54:22 -0400
committerMark Felder <feld@feld.me>2024-06-11 18:55:10 -0400
commit5c8afbe646c874eea32d7063aa499c97191f3a6e (patch)
tree9d6b80dcc9928536fe60c09826b05e6f0db1bb27
parent6a9d9da26feefe9b19e8072fd378f01a977b9d1a (diff)
downloadpleroma-5c8afbe646c874eea32d7063aa499c97191f3a6e.tar.gz
pleroma-5c8afbe646c874eea32d7063aa499c97191f3a6e.zip
Fix tests
-rw-r--r--lib/pleroma/web/push/impl.ex10
-rw-r--r--test/pleroma/web/push/impl_test.exs7
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
index 2bcfa97f5..d71e134cb 100644
--- a/lib/pleroma/web/push/impl.ex
+++ b/lib/pleroma/web/push/impl.ex
@@ -21,9 +21,7 @@ defmodule Pleroma.Web.Push.Impl do
@doc "Builds webpush notification payloads for the subscriptions enabled by the receiving user"
@spec build(Notification.t()) ::
- list(%{content: map(), subscription: Subscription.t()})
- | :error
- | {:error, :unknown_type}
+ list(%{content: map(), subscription: Subscription.t()}) | []
def build(
%{
activity: %{data: %{"type" => activity_type}} = activity,
@@ -62,9 +60,9 @@ defmodule Pleroma.Web.Push.Impl do
end)
end
- def build(_) do
- Logger.warning("Unknown notification type")
- {:error, :unknown_type}
+ def build(notif) do
+ Logger.warning("WebPush: unknown activity type: #{inspect(notif)}")
+ []
end
@doc "Deliver push notification to the provided webpush subscription"
diff --git a/test/pleroma/web/push/impl_test.exs b/test/pleroma/web/push/impl_test.exs
index 0eead956f..169c380c7 100644
--- a/test/pleroma/web/push/impl_test.exs
+++ b/test/pleroma/web/push/impl_test.exs
@@ -5,6 +5,7 @@
defmodule Pleroma.Web.Push.ImplTest do
use Pleroma.DataCase, async: true
+ import ExUnit.CaptureLog
import Mox
import Pleroma.Factory
@@ -62,8 +63,10 @@ defmodule Pleroma.Web.Push.ImplTest do
end
@tag capture_log: true
- test "returns error if notif does not match " do
- assert Impl.build(%{}) == {:error, :unknown_type}
+ test "returns error if notification activity type does not match" do
+ assert capture_log(fn ->
+ assert Impl.build(%{}) == []
+ end) =~ "WebPush: unknown activity type"
end
@tag capture_log: true