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)