X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fpleroma_api%2Fcontrollers%2Fchat_controller.ex;h=c8ef3d91511a247531749918bb981ec79e592687;hb=0883a706dc376fdfb7de9df1366803e87c8e7c98;hp=002b750829bf684fe9bc56d2d2974ef9d5272373;hpb=801e668a97adff4a33451dd7bb48799562ed8796;p=akkoma diff --git a/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex b/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex index 002b75082..c8ef3d915 100644 --- a/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex @@ -17,7 +17,6 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do alias Pleroma.Web.PleromaAPI.ChatView import Ecto.Query - import Pleroma.Web.ActivityPub.ObjectValidator, only: [stringify_keys: 1] action_fallback(Pleroma.Web.MastodonAPI.FallbackController) @@ -109,10 +108,13 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do end end - def mark_as_read(%{assigns: %{user: %{id: user_id}}} = conn, %{id: id}) do + def mark_as_read( + %{body_params: %{last_read_id: last_read_id}, assigns: %{user: %{id: user_id}}} = conn, + %{id: id} + ) do with %Chat{} = chat <- Repo.get_by(Chat, id: id, user_id: user_id), {_n, _} <- - MessageReference.set_all_seen_for_chat(chat, conn.body_params[:last_read_id]) do + MessageReference.set_all_seen_for_chat(chat, last_read_id) do conn |> put_view(ChatView) |> render("show.json", chat: chat) @@ -124,7 +126,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do cm_refs = chat |> MessageReference.for_chat_query() - |> Pagination.fetch_paginated(params |> stringify_keys()) + |> Pagination.fetch_paginated(params) conn |> put_view(MessageReferenceView) @@ -137,7 +139,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do end end - def index(%{assigns: %{user: %{id: user_id} = user}} = conn, params) do + def index(%{assigns: %{user: %{id: user_id} = user}} = conn, _params) do blocked_ap_ids = User.blocked_users_ap_ids(user) chats = @@ -146,7 +148,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do where: c.recipient not in ^blocked_ap_ids, order_by: [desc: c.updated_at] ) - |> Pagination.fetch_paginated(params |> stringify_keys) + |> Repo.all() conn |> put_view(ChatView)