X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fweb%2Fcommon_api%2Futils.ex;h=9587dfa2511aed24214f528ef263f95de76dfa34;hb=4a9d3a1f28bb89d534a859562a5209543650de9c;hp=d57ba4209f459ef74df42bc83c30b466b643e133;hpb=2a475622eea5550c9ab455c4e86212fc09ee9c58;p=akkoma diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index d57ba4209..9587dfa25 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPI.Utils do @@ -65,8 +65,13 @@ defmodule Pleroma.Web.CommonAPI.Utils do {Enum.map(participation.recipients, & &1.ap_id), []} end - def get_to_and_cc(%{visibility: "public"} = draft) do - to = [public_uri(draft) | draft.mentions] + def get_to_and_cc(%{visibility: visibility} = draft) when visibility in ["public", "local"] do + to = + case visibility do + "public" -> [Pleroma.Constants.as_public() | draft.mentions] + "local" -> [Pleroma.Constants.as_local_public() | draft.mentions] + end + cc = [draft.user.follower_address] if draft.in_reply_to do @@ -78,7 +83,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do def get_to_and_cc(%{visibility: "unlisted"} = draft) do to = [draft.user.follower_address | draft.mentions] - cc = [public_uri(draft)] + cc = [Pleroma.Constants.as_public()] if draft.in_reply_to do {Enum.uniq([draft.in_reply_to.data["actor"] | to]), cc} @@ -103,9 +108,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do def get_to_and_cc(%{visibility: {:list, _}, mentions: mentions}), do: {mentions, []} - defp public_uri(%{params: %{local_only: true}}), do: Pleroma.Constants.as_local_public() - defp public_uri(_), do: Pleroma.Constants.as_public() - def get_addressed_users(_, to) when is_list(to) do User.get_ap_ids_by_nicknames(to) end @@ -263,7 +265,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do def format_input(text, format, options \\ []) @doc """ - Formatting text to plain text. + Formatting text to plain text, BBCode, HTML, or Markdown """ def format_input(text, "text/plain", options) do text @@ -274,9 +276,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do end).() end - @doc """ - Formatting text as BBCode. - """ def format_input(text, "text/bbcode", options) do text |> String.replace(~r/\r/, "") @@ -286,18 +285,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do |> Formatter.linkify(options) end - @doc """ - Formatting text to html. - """ def format_input(text, "text/html", options) do text |> Formatter.html_escape("text/html") |> Formatter.linkify(options) end - @doc """ - Formatting text to markdown. - """ def format_input(text, "text/markdown", options) do text |> Formatter.mentions_escape(options) @@ -326,7 +319,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do defp add_in_reply_to(object, nil), do: object defp add_in_reply_to(object, in_reply_to) do - with %Object{} = in_reply_to_object <- Object.normalize(in_reply_to) do + with %Object{} = in_reply_to_object <- Object.normalize(in_reply_to, fetch: false) do Map.put(object, "inReplyTo", in_reply_to_object.data["id"]) else _ -> object @@ -406,7 +399,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do %Activity{data: %{"to" => _to, "type" => type} = data} = activity ) when type == "Create" do - object = Object.normalize(activity, false) + object = Object.normalize(activity, fetch: false) object_data = cond do