Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / lib / pleroma / web / pleroma_api / controllers / chat_controller.ex
index 1ef3477c8874bc01753b26a7bfb32d7195414217..04f136dcd77009bd92d312157966c71c735a5c48 100644 (file)
@@ -27,7 +27,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
 
   plug(
     OAuthScopesPlug,
-    %{scopes: ["read:statuses"]} when action in [:messages, :index]
+    %{scopes: ["read:statuses"]} when action in [:messages, :index, :show]
   )
 
   plug(OpenApiSpex.Plug.CastAndValidate, render_error: Pleroma.Web.ApiSpec.RenderError)
@@ -100,4 +100,12 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
       |> render("show.json", chat: chat)
     end
   end
+
+  def show(%{assigns: %{user: user}} = conn, params) do
+    with %Chat{} = chat <- Repo.get_by(Chat, user_id: user.id, id: params[:id]) do
+      conn
+      |> put_view(ChatView)
+      |> render("show.json", chat: chat)
+    end
+  end
 end