Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / lib / pleroma / web / pleroma_api / controllers / chat_controller.ex
index bedae73bd8439b8c1c123d15a02ea66856409c36..450d85332c7dc45d3340e5ed4bd1785e413281ac 100644 (file)
@@ -36,14 +36,16 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
   defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.ChatOperation
 
   def post_chat_message(
-        %{body_params: %{content: content}, assigns: %{user: %{id: user_id} = user}} = conn,
+        %{body_params: %{content: content} = params, assigns: %{user: %{id: user_id} = user}} =
+          conn,
         %{
           id: id
         }
       ) do
     with %Chat{} = chat <- Repo.get_by(Chat, id: id, user_id: user_id),
          %User{} = recipient <- User.get_cached_by_ap_id(chat.recipient),
-         {:ok, activity} <- CommonAPI.post_chat_message(user, recipient, content),
+         {:ok, activity} <-
+           CommonAPI.post_chat_message(user, recipient, content, media_id: params[:media_id]),
          message <- Object.normalize(activity) do
       conn
       |> put_view(ChatMessageView)