diff options
author | Sachin Joshi <satchin.joshi@gmail.com> | 2019-05-01 00:21:30 +0545 |
---|---|---|
committer | Sachin Joshi <satchin.joshi@gmail.com> | 2019-05-01 00:21:30 +0545 |
commit | cd6da3606b0170b1a5c7d64b96f1621896cc0930 (patch) | |
tree | 76086dd4145017de644bdeb17a389bb4d8c7a298 /lib/pleroma/web/common_api | |
parent | 963d5774af7efb57fa306b3ac164049f8958a72c (diff) | |
parent | 77690b9d03facf74483e3379f72b5b51c9f1bd4e (diff) | |
download | pleroma-cd6da3606b0170b1a5c7d64b96f1621896cc0930.tar.gz |
Merge branch 'develop' into bugfix/web-notification-special-char
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 12 | ||||
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 16 |
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 6458a3449..ecd183110 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -4,6 +4,7 @@ defmodule Pleroma.Web.CommonAPI do alias Pleroma.Activity + alias Pleroma.Bookmark alias Pleroma.Formatter alias Pleroma.Object alias Pleroma.ThreadMute @@ -282,9 +283,18 @@ defmodule Pleroma.Web.CommonAPI do end end + def bookmarked?(user, activity) do + with %Bookmark{} <- Bookmark.get(user.id, activity.id) do + true + else + _ -> + false + end + end + def report(user, data) do with {:account_id, %{"account_id" => account_id}} <- {:account_id, data}, - {:account, %User{} = account} <- {:account, User.get_by_id(account_id)}, + {:account, %User{} = account} <- {:account, User.get_cached_by_id(account_id)}, {:ok, {content_html, _, _}} <- make_report_content_html(data["comment"]), {:ok, statuses} <- get_report_statuses(account, data), {:ok, activity} <- 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 |