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()
This commit is contained in:
Mark Felder 2024-01-27 16:02:26 -05:00
parent 52e18a6249
commit 26a95e5787
2 changed files with 7 additions and 4 deletions

View file

@ -24,8 +24,11 @@ defmodule Pleroma.Web.ApiSpec.PleromaNotificationOperation do
request_body("Parameters", %Schema{ request_body("Parameters", %Schema{
type: :object, type: :object,
properties: %{ properties: %{
id: %Schema{type: :integer, description: "A single notification ID to read"}, "id" => %Schema{type: :integer, description: "A single notification ID to read"},
max_id: %Schema{type: :integer, description: "Read all notifications up to this ID"} "max_id" => %Schema{
type: :integer,
description: "Read all notifications up to this ID"
}
} }
}), }),
security: [%{"oAuth" => ["write:notifications"]}], security: [%{"oAuth" => ["write:notifications"]}],

View file

@ -16,7 +16,7 @@ defmodule Pleroma.Web.PleromaAPI.NotificationController do
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaNotificationOperation 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 with {:ok, notification} <- Notification.read_one(user, notification_id) do
render(conn, "show.json", notification: notification, for: user) render(conn, "show.json", notification: notification, for: user)
else else
@ -27,7 +27,7 @@ defmodule Pleroma.Web.PleromaAPI.NotificationController do
end end
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 = notifications =
user user
|> Notification.set_read_up_to(max_id) |> Notification.set_read_up_to(max_id)