projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into feature/disable-account
[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 087778dfe9f54b47cce5ab62c07ef928be4ace3f..887f878c440ed2a6e6550017596c3f3764d1db12 100644
(file)
--- a/
lib/pleroma/web/common_api/utils.ex
+++ b/
lib/pleroma/web/common_api/utils.ex
@@
-12,6
+12,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.ActivityPub.Utils
+ alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.Endpoint
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.Endpoint
alias Pleroma.Web.MediaProxy
@@
-194,11
+195,10
@@
defmodule Pleroma.Web.CommonAPI.Utils do
Formatting text to markdown.
"""
def format_input(text, "text/markdown", options) do
Formatting text to markdown.
"""
def format_input(text, "text/markdown", options) do
- options = Keyword.put(options, :mentions_escape, true)
-
text
text
+ |> Formatter.mentions_escape(options)
+ |> Earmark.as_html!()
|> Formatter.linkify(options)
|> Formatter.linkify(options)
- |> (fn {text, mentions, tags} -> {Earmark.as_html!(text), mentions, tags} end).()
|> Formatter.html_escape("text/html")
end
|> Formatter.html_escape("text/html")
end
@@
-208,7
+208,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
context,
content_html,
attachments,
context,
content_html,
attachments,
- in
ReplyT
o,
+ in
_reply_t
o,
tags,
cw \\ nil,
cc \\ []
tags,
cw \\ nil,
cc \\ []
@@
-225,10
+225,11
@@
defmodule Pleroma.Web.CommonAPI.Utils do
"tag" => tags |> Enum.map(fn {_, tag} -> tag end) |> Enum.uniq()
}
"tag" => tags |> Enum.map(fn {_, tag} -> tag end) |> Enum.uniq()
}
- if inReplyTo do
+ if in_reply_to do
+ in_reply_to_object = Object.normalize(in_reply_to)
+
object
object
- |> Map.put("inReplyTo", inReplyTo.data["object"]["id"])
- |> Map.put("inReplyToStatusId", inReplyTo.id)
+ |> Map.put("inReplyTo", in_reply_to_object.data["id"])
else
object
end
else
object
end
@@
-283,7
+284,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
end
def confirm_current_password(user, password) do
end
def confirm_current_password(user, password) do
- with %User{local: true} = db_user <- User.get_by_id(user.id),
+ with %User{local: true} = db_user <- User.get_
cached_
by_id(user.id),
true <- Pbkdf2.checkpw(password, db_user.password_hash) do
{:ok, db_user}
else
true <- Pbkdf2.checkpw(password, db_user.password_hash) do
{:ok, db_user}
else
@@
-293,7
+294,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
def emoji_from_profile(%{info: _info} = user) do
(Formatter.get_emoji(user.bio) ++ Formatter.get_emoji(user.name))
def emoji_from_profile(%{info: _info} = user) do
(Formatter.get_emoji(user.bio) ++ Formatter.get_emoji(user.name))
- |> Enum.map(fn {shortcode, url} ->
+ |> Enum.map(fn {shortcode, url
, _
} ->
%{
"type" => "Emoji",
"icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}#{url}"},
%{
"type" => "Emoji",
"icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}#{url}"},
@@
-337,13
+338,14
@@
defmodule Pleroma.Web.CommonAPI.Utils do
def maybe_notify_subscribers(
recipients,
def maybe_notify_subscribers(
recipients,
- %Activity{data: %{"actor" => actor, "type" => type}}
+ %Activity{data: %{"actor" => actor, "type" => type}}
= activity
)
when type == "Create" do
)
when type == "Create" do
- with %User{} = user <- User.get_by_ap_id(actor) do
+ with %User{} = user <- User.get_
cached_
by_ap_id(actor) do
subscriber_ids =
user
subscriber_ids =
user
- |> User.subscribed_users()
+ |> User.subscribers()
+ |> Enum.filter(&Visibility.visible_for_user?(activity, &1))
|> Enum.map(& &1.ap_id)
recipients ++ subscriber_ids
|> Enum.map(& &1.ap_id)
recipients ++ subscriber_ids