commit: 1b3c84e241f8ed1066d113346365ce489971ac14
parent 17ebb2df8404474ef66c6a38e974143166b5e49b
Author: Mark Felder <feld@feld.me>
Date: Tue, 28 May 2024 09:58:44 -0400
Dialyzer: no_local_return
WebPushEncryption.send_web_push/4 was written to raise on erroroneus input, so we must guard against that.
lib/pleroma/web/push/impl.ex:65:no_return Function push_message/4 has no local return.
Diffstat:
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
@@ -63,19 +63,25 @@ defmodule Pleroma.Web.Push.Impl do
@doc "Push message to web"
def push_message(body, sub, api_key, subscription) do
- case WebPushEncryption.send_web_push(body, sub, api_key) do
- {:ok, %{status: code}} when code in 400..499 ->
- Logger.debug("Removing subscription record")
- Repo.delete!(subscription)
- :ok
-
- {:ok, %{status: code}} when code in 200..299 ->
- :ok
-
- {:ok, %{status: code}} ->
- Logger.error("Web Push Notification failed with code: #{code}")
- :error
-
+ try do
+ case WebPushEncryption.send_web_push(body, sub, api_key) do
+ {:ok, %{status: code}} when code in 400..499 ->
+ Logger.debug("Removing subscription record")
+ Repo.delete!(subscription)
+ :ok
+
+ {:ok, %{status: code}} when code in 200..299 ->
+ :ok
+
+ {:ok, %{status: code}} ->
+ Logger.error("Web Push Notification failed with code: #{code}")
+ :error
+
+ error ->
+ Logger.error("Web Push Notification failed with #{inspect(error)}")
+ :error
+ end
+ rescue
error ->
Logger.error("Web Push Notification failed with #{inspect(error)}")
:error