projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request 'remove comment about old openssl versions in nginx config' (...
[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 61af71acd206f75a46c4892472e549483d9d7e2c..22594be4605f24fb81b3166f1b002e9aa1df4c15 100644
(file)
--- a/
lib/pleroma/web/common_api/utils.ex
+++ b/
lib/pleroma/web/common_api/utils.ex
@@
-17,7
+17,6
@@
defmodule Pleroma.Web.CommonAPI.Utils do
alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.CommonAPI.ActivityDraft
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.CommonAPI.ActivityDraft
alias Pleroma.Web.MediaProxy
- alias Pleroma.Web.Plugs.AuthenticationPlug
alias Pleroma.Web.Utils.Params
require Logger
alias Pleroma.Web.Utils.Params
require Logger
@@
-37,7
+36,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
def attachments_from_ids_no_descs(ids) do
Enum.map(ids, fn media_id ->
def attachments_from_ids_no_descs(ids) do
Enum.map(ids, fn media_id ->
- case
Repo.get(Object,
media_id) do
+ case
get_attachment(
media_id) do
%Object{data: data} -> data
_ -> nil
end
%Object{data: data} -> data
_ -> nil
end
@@
-51,13
+50,17
@@
defmodule Pleroma.Web.CommonAPI.Utils do
{_, descs} = Jason.decode(descs_str)
Enum.map(ids, fn media_id ->
{_, descs} = Jason.decode(descs_str)
Enum.map(ids, fn media_id ->
- with %Object{data: data} <-
Repo.get(Object,
media_id) do
+ with %Object{data: data} <-
get_attachment(
media_id) do
Map.put(data, "name", descs[media_id])
end
end)
|> Enum.reject(&is_nil/1)
end
Map.put(data, "name", descs[media_id])
end
end)
|> Enum.reject(&is_nil/1)
end
+ defp get_attachment(media_id) do
+ Repo.get(Object, media_id)
+ end
+
@spec get_to_and_cc(ActivityDraft.t()) :: {list(String.t()), list(String.t())}
def get_to_and_cc(%{in_reply_to_conversation: %Participation{} = participation}) do
@spec get_to_and_cc(ActivityDraft.t()) :: {list(String.t()), list(String.t())}
def get_to_and_cc(%{in_reply_to_conversation: %Participation{} = participation}) do
@@
-219,7
+222,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
|> maybe_add_attachments(draft.attachments, attachment_links)
end
|> maybe_add_attachments(draft.attachments, attachment_links)
end
- def
p
get_content_type(content_type) do
+ def get_content_type(content_type) do
if Enum.member?(Config.get([:instance, :allowed_post_formats]), content_type) do
content_type
else
if Enum.member?(Config.get([:instance, :allowed_post_formats]), content_type) do
content_type
else
@@
-285,11
+288,11
@@
defmodule Pleroma.Web.CommonAPI.Utils do
def format_input(text, "text/x.misskeymarkdown", options) do
text
def format_input(text, "text/x.misskeymarkdown", options) do
text
+ |> Formatter.markdown_to_html()
+ |> MfmParser.Parser.parse()
+ |> MfmParser.Encoder.to_html()
|> Formatter.linkify(options)
|> Formatter.linkify(options)
- |> Formatter.html_escape("text/x.misskeymarkdown")
- |> (fn {text, mentions, tags} ->
- {String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
- end).()
+ |> Formatter.html_escape("text/html")
end
def format_input(text, "text/markdown", options) do
end
def format_input(text, "text/markdown", options) do
@@
-352,7
+355,7
@@
defmodule Pleroma.Web.CommonAPI.Utils do
@spec confirm_current_password(User.t(), String.t()) :: {:ok, User.t()} | {:error, String.t()}
def confirm_current_password(user, password) do
with %User{local: true} = db_user <- User.get_cached_by_id(user.id),
@spec confirm_current_password(User.t(), String.t()) :: {:ok, User.t()} | {:error, String.t()}
def confirm_current_password(user, password) do
with %User{local: true} = db_user <- User.get_cached_by_id(user.id),
- true <-
AuthenticationPlug
.checkpw(password, db_user.password_hash) do
+ true <-
Pleroma.Password
.checkpw(password, db_user.password_hash) do
{:ok, db_user}
else
_ -> {:error, dgettext("errors", "Invalid password.")}
{:ok, db_user}
else
_ -> {:error, dgettext("errors", "Invalid password.")}