Merge remote-tracking branch 'upstream/develop' into registration-workflow
[akkoma] / lib / pleroma / web / pleroma_api / controllers / notification_controller.ex
index 0b2f678c50212b46bdffb7711ae73cf5df47f3a9..fa32aaa844582f29fd0c61b71b253348d2d3752b 100644 (file)
@@ -6,15 +6,19 @@ defmodule Pleroma.Web.PleromaAPI.NotificationController do
   use Pleroma.Web, :controller
 
   alias Pleroma.Notification
-  alias Pleroma.Plugs.OAuthScopesPlug
 
   plug(Pleroma.Web.ApiSpec.CastAndValidate)
-  plug(OAuthScopesPlug, %{scopes: ["write:notifications"]} when action == :mark_as_read)
+
+  plug(
+    Pleroma.Web.Plugs.OAuthScopesPlug,
+    %{scopes: ["write:notifications"]} when action == :mark_as_read
+  )
+
   plug(:put_view, Pleroma.Web.MastodonAPI.NotificationView)
 
   defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaNotificationOperation
 
-  def mark_as_read(%{assigns: %{user: user}} = conn, %{id: notification_id}) 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
@@ -25,7 +29,7 @@ defmodule Pleroma.Web.PleromaAPI.NotificationController do
     end
   end
 
-  def mark_as_read(%{assigns: %{user: user}} = conn, %{max_id: max_id}) 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)