Merge branch 'harmonize_return_types_in_user_module' into 'develop'
[akkoma] / lib / pleroma / web / common_api / common_api.ex
index d6eb843f7c2a10b79117e62046b59b0f8adf8d3a..ecd1831107d26efeba18d9eb483dbe18964b3160 100644 (file)
@@ -4,6 +4,7 @@
 
 defmodule Pleroma.Web.CommonAPI do
   alias Pleroma.Activity
+  alias Pleroma.Bookmark
   alias Pleroma.Formatter
   alias Pleroma.Object
   alias Pleroma.ThreadMute
@@ -127,7 +128,7 @@ defmodule Pleroma.Web.CommonAPI do
       in_reply_to ->
         # XXX: these heuristics should be moved out of MastodonAPI.
         with %Object{} = object <- Object.normalize(in_reply_to) do
-          Pleroma.Web.MastodonAPI.StatusView.get_visibility(object.data)
+          Pleroma.Web.MastodonAPI.StatusView.get_visibility(object)
         end
     end
   end
@@ -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} <-