From 26a95e57873630491066687d2a216ab6e01549b0 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sat, 27 Jan 2024 16:02:26 -0500 Subject: [PATCH] Pleroma.Web.PleromaAPI.NotificationController: dialyzer errors lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex:53:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:list => _, _ => _}, _ => _ }, <<106, 111, 98, 32, 115, 116, 97, 114, 116, 101, 100>> ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() --- .../api_spec/operations/pleroma_notification_operation.ex | 7 +++++-- .../web/pleroma_api/controllers/notification_controller.ex | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/api_spec/operations/pleroma_notification_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_notification_operation.ex index a994345db..79990cb78 100644 --- a/lib/pleroma/web/api_spec/operations/pleroma_notification_operation.ex +++ b/lib/pleroma/web/api_spec/operations/pleroma_notification_operation.ex @@ -24,8 +24,11 @@ def mark_as_read_operation do request_body("Parameters", %Schema{ type: :object, properties: %{ - id: %Schema{type: :integer, description: "A single notification ID to read"}, - max_id: %Schema{type: :integer, description: "Read all notifications up to this ID"} + "id" => %Schema{type: :integer, description: "A single notification ID to read"}, + "max_id" => %Schema{ + type: :integer, + description: "Read all notifications up to this ID" + } } }), security: [%{"oAuth" => ["write:notifications"]}], diff --git a/lib/pleroma/web/pleroma_api/controllers/notification_controller.ex b/lib/pleroma/web/pleroma_api/controllers/notification_controller.ex index 87ea81cef..0c6ec29f5 100644 --- a/lib/pleroma/web/pleroma_api/controllers/notification_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/notification_controller.ex @@ -16,7 +16,7 @@ defmodule Pleroma.Web.PleromaAPI.NotificationController do defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaNotificationOperation - def mark_as_read(%{assigns: %{user: user}, body_params: %{id: notification_id}} = conn, _) do + def mark_as_read(%{assigns: %{user: user}, body_params: %{"id" => notification_id}} = conn, _) do with {:ok, notification} <- Notification.read_one(user, notification_id) do render(conn, "show.json", notification: notification, for: user) else @@ -27,7 +27,7 @@ def mark_as_read(%{assigns: %{user: user}, body_params: %{id: notification_id}} end end - def mark_as_read(%{assigns: %{user: user}, body_params: %{max_id: max_id}} = conn, _) do + def mark_as_read(%{assigns: %{user: user}, body_params: %{"max_id" => max_id}} = conn, _) do notifications = user |> Notification.set_read_up_to(max_id)