projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'pleroma/develop' into cycles-constants
[akkoma]
/
lib
/
pleroma
/
web
/
common_api
/
utils.ex
diff --git
a/lib/pleroma/web/common_api/utils.ex
b/lib/pleroma/web/common_api/utils.ex
index d57ba4209f459ef74df42bc83c30b466b643e133..4cc34002d11ae3c0a073abae3ddb6141a5983f24 100644
(file)
--- 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
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.Utils do
# 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
{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" -> [Utils.as_local_public() | draft.mentions]
+ end
+
cc = [draft.user.follower_address]
if draft.in_reply_to do
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]
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}
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, []}
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
def get_addressed_users(_, to) when is_list(to) do
User.get_ap_ids_by_nicknames(to)
end
@@
-215,7
+217,6
@@
defmodule Pleroma.Web.CommonAPI.Utils do
draft.status
|> format_input(content_type, options)
|> maybe_add_attachments(draft.attachments, attachment_links)
draft.status
|> format_input(content_type, options)
|> maybe_add_attachments(draft.attachments, attachment_links)
- |> maybe_add_nsfw_tag(draft.params)
end
defp get_content_type(content_type) do
end
defp get_content_type(content_type) do
@@
-226,13
+227,6
@@
defmodule Pleroma.Web.CommonAPI.Utils do
end
end
end
end
- defp maybe_add_nsfw_tag({text, mentions, tags}, %{"sensitive" => sensitive})
- when sensitive in [true, "True", "true", "1"] do
- {text, mentions, [{"#nsfw", "nsfw"} | tags]}
- end
-
- defp maybe_add_nsfw_tag(data, _), do: data
-
def make_context(_, %Participation{} = participation) do
Repo.preload(participation, :conversation).conversation.ap_id
end
def make_context(_, %Participation{} = participation) do
Repo.preload(participation, :conversation).conversation.ap_id
end
@@
-263,7
+257,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
def format_input(text, format, options \\ [])
@doc """
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
"""
def format_input(text, "text/plain", options) do
text
@@
-274,9
+268,6
@@
defmodule Pleroma.Web.CommonAPI.Utils do
end).()
end
end).()
end
- @doc """
- Formatting text as BBCode.
- """
def format_input(text, "text/bbcode", options) do
text
|> String.replace(~r/\r/, "")
def format_input(text, "text/bbcode", options) do
text
|> String.replace(~r/\r/, "")
@@
-286,22
+277,16
@@
defmodule Pleroma.Web.CommonAPI.Utils do
|> Formatter.linkify(options)
end
|> 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
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)
def format_input(text, "text/markdown", options) do
text
|> Formatter.mentions_escape(options)
- |>
Earmark.as_html!(%Earmark.Options{renderer: Pleroma.EarmarkRenderer}
)
+ |>
Formatter.markdown_to_html(
)
|> Formatter.linkify(options)
|> Formatter.html_escape("text/html")
end
|> Formatter.linkify(options)
|> Formatter.html_escape("text/html")
end
@@
-326,7
+311,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
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
Map.put(object, "inReplyTo", in_reply_to_object.data["id"])
else
_ -> object
@@
-406,7
+391,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
%Activity{data: %{"to" => _to, "type" => type} = data} = activity
)
when type == "Create" do
%Activity{data: %{"to" => _to, "type" => type} = data} = activity
)
when type == "Create" do
- object = Object.normalize(activity, false)
+ object = Object.normalize(activity, f
etch: f
alse)
object_data =
cond do
object_data =
cond do