projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'staff-plug' into 'develop'
[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 1c74ea7875760355cbfc4baf7c0a58bf7bfb69a2..33639e6954fb54f51473fb9926c02c2f56b56239 100644
(file)
--- a/
lib/pleroma/web/common_api/utils.ex
+++ b/
lib/pleroma/web/common_api/utils.ex
@@
-1,10
+1,9
@@
# 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
import Pleroma.Web.Gettext
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.Utils do
import Pleroma.Web.Gettext
- import Pleroma.Web.ControllerHelper, only: [truthy_param?: 1]
alias Calendar.Strftime
alias Pleroma.Activity
alias Calendar.Strftime
alias Pleroma.Activity
@@
-19,6
+18,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
alias Pleroma.Web.CommonAPI.ActivityDraft
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.Plugs.AuthenticationPlug
alias Pleroma.Web.CommonAPI.ActivityDraft
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.Plugs.AuthenticationPlug
+ alias Pleroma.Web.Utils.Params
require Logger
require Pleroma.Constants
require Logger
require Pleroma.Constants
@@
-69,7
+69,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
to =
case visibility do
"public" -> [Pleroma.Constants.as_public() | draft.mentions]
to =
case visibility do
"public" -> [Pleroma.Constants.as_public() | draft.mentions]
- "local" -> [
Pleroma.Constant
s.as_local_public() | draft.mentions]
+ "local" -> [
Util
s.as_local_public() | draft.mentions]
end
cc = [draft.user.follower_address]
end
cc = [draft.user.follower_address]
@@
-160,7
+160,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
|> DateTime.add(expires_in)
|> DateTime.to_iso8601()
|> DateTime.add(expires_in)
|> DateTime.to_iso8601()
- key = if truthy_param?(data.poll[:multiple]), do: "anyOf", else: "oneOf"
+ key = if
Params.
truthy_param?(data.poll[:multiple]), do: "anyOf", else: "oneOf"
poll = %{"type" => "Question", key => option_notes, "closed" => end_time}
{:ok, {poll, emoji}}
poll = %{"type" => "Question", key => option_notes, "closed" => end_time}
{:ok, {poll, emoji}}
@@
-203,7
+203,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
attachment_links =
draft.params
|> Map.get("attachment_links", Config.get([:instance, :attachment_links]))
attachment_links =
draft.params
|> Map.get("attachment_links", Config.get([:instance, :attachment_links]))
- |> truthy_param?()
+ |>
Params.
truthy_param?()
content_type = get_content_type(draft.params[:content_type])
content_type = get_content_type(draft.params[:content_type])
@@
-217,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
@@
-228,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
@@
-294,7
+286,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
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
@@
-319,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
@@
-399,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