aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/utils.ex
diff options
context:
space:
mode:
authorSachin Joshi <satchin.joshi@gmail.com>2019-05-01 00:21:30 +0545
committerSachin Joshi <satchin.joshi@gmail.com>2019-05-01 00:21:30 +0545
commitcd6da3606b0170b1a5c7d64b96f1621896cc0930 (patch)
tree76086dd4145017de644bdeb17a389bb4d8c7a298 /lib/pleroma/web/common_api/utils.ex
parent963d5774af7efb57fa306b3ac164049f8958a72c (diff)
parent77690b9d03facf74483e3379f72b5b51c9f1bd4e (diff)
downloadpleroma-cd6da3606b0170b1a5c7d64b96f1621896cc0930.tar.gz
Merge branch 'develop' into bugfix/web-notification-special-char
Diffstat (limited to 'lib/pleroma/web/common_api/utils.ex')
-rw-r--r--lib/pleroma/web/common_api/utils.ex16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index 25f498fcb..1dfe50b40 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -183,6 +183,18 @@ defmodule Pleroma.Web.CommonAPI.Utils do
end
@doc """
+ Formatting text as BBCode.
+ """
+ def format_input(text, "text/bbcode", options) do
+ text
+ |> String.replace(~r/\r/, "")
+ |> Formatter.html_escape("text/plain")
+ |> BBCode.to_html()
+ |> (fn {:ok, html} -> html end).()
+ |> Formatter.linkify(options)
+ end
+
+ @doc """
Formatting text to html.
"""
def format_input(text, "text/html", options) do
@@ -226,7 +238,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
}
if in_reply_to do
- in_reply_to_object = Object.normalize(in_reply_to.data["object"])
+ in_reply_to_object = Object.normalize(in_reply_to)
object
|> Map.put("inReplyTo", in_reply_to_object.data["id"])
@@ -284,7 +296,7 @@ defmodule Pleroma.Web.CommonAPI.Utils 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