purge chat and shout endpoints
[akkoma] / lib / pleroma / web / common_api.ex
index 3c2e7ae86bed2348eaf24a013ee5563b9d0401c9..8ab50cf2bd3fdf2b22b53a58cc3a0960c6aed1ec 100644 (file)
@@ -5,7 +5,6 @@
 defmodule Pleroma.Web.CommonAPI do
   alias Pleroma.Activity
   alias Pleroma.Conversation.Participation
-  alias Pleroma.Formatter
   alias Pleroma.Object
   alias Pleroma.ThreadMute
   alias Pleroma.User
@@ -30,57 +29,6 @@ defmodule Pleroma.Web.CommonAPI do
     end
   end
 
-  def post_chat_message(%User{} = user, %User{} = recipient, content, opts \\ []) do
-    with maybe_attachment <- opts[:media_id] && Object.get_by_id(opts[:media_id]),
-         :ok <- validate_chat_content_length(content, !!maybe_attachment),
-         {_, {:ok, chat_message_data, _meta}} <-
-           {:build_object,
-            Builder.chat_message(
-              user,
-              recipient.ap_id,
-              content |> format_chat_content,
-              attachment: maybe_attachment
-            )},
-         {_, {:ok, create_activity_data, _meta}} <-
-           {:build_create_activity, Builder.create(user, chat_message_data, [recipient.ap_id])},
-         {_, {:ok, %Activity{} = activity, _meta}} <-
-           {:common_pipeline,
-            Pipeline.common_pipeline(create_activity_data,
-              local: true,
-              idempotency_key: opts[:idempotency_key]
-            )} do
-      {:ok, activity}
-    else
-      {:common_pipeline, {:reject, _} = e} -> e
-      e -> e
-    end
-  end
-
-  defp format_chat_content(nil), do: nil
-
-  defp format_chat_content(content) do
-    {text, _, _} =
-      content
-      |> Formatter.html_escape("text/plain")
-      |> Formatter.linkify()
-      |> (fn {text, mentions, tags} ->
-            {String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
-          end).()
-
-    text
-  end
-
-  defp validate_chat_content_length(_, true), do: :ok
-  defp validate_chat_content_length(nil, false), do: {:error, :no_content}
-
-  defp validate_chat_content_length(content, _) do
-    if String.length(content) <= Pleroma.Config.get([:instance, :chat_limit]) do
-      :ok
-    else
-      {:error, :content_too_long}
-    end
-  end
-
   def unblock(blocker, blocked) do
     with {_, %Activity{} = block} <- {:fetch_block, Utils.fetch_latest_block(blocker, blocked)},
          {:ok, unblock_data, _} <- Builder.undo(blocker, block),